changing date format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Anglophobe
Forum Newbie
Posts: 11
Joined: Tue May 09, 2006 11:50 am

changing date format

Post 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
sava
Forum Newbie
Posts: 8
Joined: Mon May 15, 2006 10:04 am

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Have a look at the Date and Time functions section in the mysql manual... (DATE_FORMAT in particular)
Post Reply