woolyg Posted November 7, 2007 Share Posted November 7, 2007 Hi all, Safe in the knowledge that TIMESTAMP format is DATETIME's ugly older sister, if I have a DATETIME string (2007-10-25 02:42:52) that I need to switch to TIMESTAMP. Maybe I'm into ugly old chicks, who knows. Can anyone help? Cheers, WoolyG Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 7, 2007 Share Posted November 7, 2007 you can use the UNIX_TIMESTAMP function in mysql http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_unix-timestamp Quote Link to comment Share on other sites More sharing options...
woolyg Posted November 7, 2007 Author Share Posted November 7, 2007 Is there a way to do it in PHP? I just need to run a quick function using TIMESTAMP as opposed to DATETIME.. Quote Link to comment Share on other sites More sharing options...
obsidian Posted November 7, 2007 Share Posted November 7, 2007 Is there a way to do it in PHP? I just need to run a quick function using TIMESTAMP as opposed to DATETIME.. I'm not positive I follow, but if you're simply trying to translate a DATETIME into a unix timestamp, just use strtotime(): <?php $dt = '2007-10-04 00:00:00'; $ts = strtotime($dt); if ($ts !== FALSE) { // Success! echo "Timestamp = {$ts}"; } ?> Quote Link to comment Share on other sites More sharing options...
woolyg Posted November 7, 2007 Author Share Posted November 7, 2007 Nice one, I'll get this going and try to achieve it. Thanks for your help guys. Woolyg Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.