Jump to content

Convert into datetime MySQL format.


oskare100

Recommended Posts

Hello,
I have one column with dates stored in VARCHAR like this: 14:08:41 Nov 20, 2006.

Now I need to move all rows in that table and insert them in another table where I need store the times in the datetime MySQL format.

So I need to convert all times like 14:08:41 Nov 20, 2006 into datetime like 0000-00-00 00:00:00. How can I do that?

Best Regards
Link to comment
https://forums.phpfreaks.com/topic/35389-convert-into-datetime-mysql-format/
Share on other sites

you can try converting the old format to the new using [code=php:0]date("Y-m-d H:i:s",strtotime($oldtimeformat))[/code] -- but don't just feed that to your database. Sometimes strtotime works awesome, sometimes it's not so smart. If it works, great, if not, reply back and we'll do it the hard way.

[url=http://us3.php.net/strtotime]strtotime()[/url]
[url=http://us2.php.net/date]date()[/url]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.