Page 1 of 1

changing date format

Posted: Mon May 15, 2006 12:38 pm
by Anglophobe
I'm looking to take a date input format such as 05-15-06, store it in MySQL (I think the only way is 2006-05-15), and then output it back again as 05-15-06. It would be really easy if MySQL stored dates the way I want, but I don't think it does, and I need it to be able to sort by date. Thanks

Posted: Mon May 15, 2006 12:59 pm
by sava
On my opinion it better to use unix timestamp: time(); ().
It simple digital value and u can easy get date in different formats using date() function:

Code: Select all

echo time(); // 1147715737
echo date('m-d-y',1147715737);  // 05-15-06

Posted: Mon May 15, 2006 1:00 pm
by timvw
Have a look at the Date and Time functions section in the mysql manual... (DATE_FORMAT in particular)