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 Link to comment https://forums.phpfreaks.com/topic/76348-solved-translating-datetime-into-timestamp/ 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 Link to comment https://forums.phpfreaks.com/topic/76348-solved-translating-datetime-into-timestamp/#findComment-386546 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.. Link to comment https://forums.phpfreaks.com/topic/76348-solved-translating-datetime-into-timestamp/#findComment-387009 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}"; } ?> Link to comment https://forums.phpfreaks.com/topic/76348-solved-translating-datetime-into-timestamp/#findComment-387028 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 Link to comment https://forums.phpfreaks.com/topic/76348-solved-translating-datetime-into-timestamp/#findComment-387096 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.