RE: [PHP] Date Conversions?
| From: | Mike Johnson | Date: | Mon, 15 Nov 2004 20:15:42 +0000 |
| Subject: | RE: [PHP] Date Conversions? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-202084@lists.php.net to get a copy of this message | ||
From: Robert Sossomon [mailto:robert_sossomon@ncsu.edu]
> I have a date in format YY-MM-DD in a MySQL table. I need to
> pull it back to display it in either format: MM-DD-YY or
> Month Day, Year format.
>
> I can't figure out how to write the query to do it, and am
> not sure how to make PHP just parse the one given and dump it
> back out in the way I need it. Any suggestions?
I don't know how well PHP would handle the 2-digit year concept, so you
might be better off doing it in the query. Something like this:
SELECT DATE_FORMAT(date_field, '%m-%d-%y') AS date_format_1,
DATE_FORMAT(date_field, '%M %e, %y') AS date_format_2...
HTH!
--
Mike Johnson Smarter Living, Inc.
Web Developer www.smarterliving.com
mike@smarterliving.com (617) 886-5539