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 Quote 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 Quote 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'); Quote 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 Quote 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 ? Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.