ajoo Posted August 11, 2013 Share Posted August 11, 2013 Hi guys, I found that this much asked question on the net has no real straight forward answer. So i ask this again. $date = ('2013-07-08 12:30:30'); how can i change this date to a Unix time stamp in the simplest possible manner just as it is possible to convert a timestamp to datetime in one line. Thanks to all again. Link to comment https://forums.phpfreaks.com/topic/281052-convert-a-date-to-timestamp/ Share on other sites More sharing options...
Barand Posted August 11, 2013 Share Posted August 11, 2013 $timestamp = strtotime($date); Link to comment https://forums.phpfreaks.com/topic/281052-convert-a-date-to-timestamp/#findComment-1444420 Share on other sites More sharing options...
ajoo Posted August 11, 2013 Author Share Posted August 11, 2013 Thank you sir !! In fact i found another method which I'll post here echo strtotime('2011-02-27 02:04:46'); // 1 SAME AS BARAND - THANKS$dt = new DateTime('2011-02-27 02:04:46'); // 2 echo $dt->format('U'); Thnaks loads. hope this will help some more like me. Link to comment https://forums.phpfreaks.com/topic/281052-convert-a-date-to-timestamp/#findComment-1444422 Share on other sites More sharing options...
Barand Posted August 13, 2013 Share Posted August 13, 2013 or echo $dt->getTimestamp(); // 3 Link to comment https://forums.phpfreaks.com/topic/281052-convert-a-date-to-timestamp/#findComment-1444673 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.