Reply to Re: displaying pre-1970 dates

Your name:

Reply:


Posted by Bosconian on 02/05/06 21:59

"Chuck Anderson" <websiteaddress@seemy.sig> wrote in message
news:zJKdnbLTB-hYmHjenZ2dnUVZ_v2dnZ2d@comcast.com...
> Bosconian wrote:
>
> >I must be having a brain freeze because I can't figure out how to display
> >dates older than 1970.
> >
> >I have birth dates stored in MySQL as "date" data types (exp.
1955-04-06).
> >I'd like to display as "April 4, 1955".
> >
> >I've tried using date("F j, Y"), but only get "December 31, 1969".
> >
> >I'm using PHP 4.3.8. Any suggestions would be appreciated.
> >
> >
> >
> >
> $months = array('', 'January', 'February', 'March', 'April', 'May',
> 'June', 'July', 'August', 'September', 'October', 'November', 'December');
>
> Separate year, month and day with strtok or explode and format it
yourself.
>

Yup, that's exactly what I did. I made the months array global because it's
used elsewhere.

// custom output function for displaying pre-1970 dates; expects
"yyyy-mm-dd" date format
// returns full textual month, numeric day (w/o leading zeros) and numeric
4-digit year
function format_date($date) {
global $months;
return $months[intval(substr($date, 5, 2))] . ' ' . intval(substr($date,
8, 2)) . ', ' . substr($date, 0, 4);
}

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация