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
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.