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!!
convert datetime format
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: convert datetime format
You probably want a four digit year, and use H for 24 hour time or h for 12 hour:
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
Code: Select all
$new_date = date('Y-m-d h:i:s', strtotime($old_date));mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.