hoangthi Posted April 28, 2012 Share Posted April 28, 2012 I have a string in php: Sat, 28 Apr 2012 05:09:45 GMT I want to convert it to timestamp Example: 1335594473 Link to comment https://forums.phpfreaks.com/topic/261749-how-to-convert-normal-time-to-timestamp/ Share on other sites More sharing options...
kicken Posted April 28, 2012 Share Posted April 28, 2012 strtotime Link to comment https://forums.phpfreaks.com/topic/261749-how-to-convert-normal-time-to-timestamp/#findComment-1341313 Share on other sites More sharing options...
hoangthi Posted April 28, 2012 Author Share Posted April 28, 2012 can i use it ? $dt = new DateTime('Sat, 28 Apr 2012 05:09:45 GMT'); Link to comment https://forums.phpfreaks.com/topic/261749-how-to-convert-normal-time-to-timestamp/#findComment-1341316 Share on other sites More sharing options...
creata.physics Posted April 28, 2012 Share Posted April 28, 2012 I don't know why you're using the DateTime class when kicken specifically said to use strtotime() echo strtotime("Sat, 28 Apr 2012 05:09:45 GMT"); Will return: 1335589785 Link to comment https://forums.phpfreaks.com/topic/261749-how-to-convert-normal-time-to-timestamp/#findComment-1341317 Share on other sites More sharing options...
hoangthi Posted April 28, 2012 Author Share Posted April 28, 2012 so what should i use ? Link to comment https://forums.phpfreaks.com/topic/261749-how-to-convert-normal-time-to-timestamp/#findComment-1341318 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.