Page 1 of 1
convert datetime format
Posted: Mon Oct 11, 2010 12:29 pm
by playwright
I have multiple datetimes. The format is dd-mm-yy, hh:mm. I want to insert it into a table using mysql. However mysql format is yy-mm-dd, hh:mm:ss. How can i do it and what type should i use (datetime?timestamp?).
Thanks for your help!!
Re: convert datetime format
Posted: Mon Oct 11, 2010 1:00 pm
by AbraCadaver
You probably want a four digit year, and use H for 24 hour time or h for 12 hour:
Code: Select all
$new_date = date('Y-m-d h:i:s', strtotime($old_date));
datetime or timestamp depends on what you need. You can read the differences here:
http://dev.mysql.com/doc/refman/5.1/en/datetime.html