monkeytooth Posted September 22, 2009 Share Posted September 22, 2009 Whats the best way to convert "Tue, 22 Sep 2009 04:00:40 GMT" to a unix timestamp, im looking around, playing around and I can't seem to get it to work right. I know I should tempt to phase it like "2009-09-22 04:01:00" and pump it through date() but some of the things I am working on currently are 3rd party and I have no control over their outputs. Link to comment https://forums.phpfreaks.com/topic/175101-timestamp-conversion-rss-to-unix/ Share on other sites More sharing options...
thebadbad Posted September 22, 2009 Share Posted September 22, 2009 strtotime() Link to comment https://forums.phpfreaks.com/topic/175101-timestamp-conversion-rss-to-unix/#findComment-922881 Share on other sites More sharing options...
monkeytooth Posted September 22, 2009 Author Share Posted September 22, 2009 I was playin with that, couldnt get it right.. but ill try again Link to comment https://forums.phpfreaks.com/topic/175101-timestamp-conversion-rss-to-unix/#findComment-922883 Share on other sites More sharing options...
Bricktop Posted September 22, 2009 Share Posted September 22, 2009 Hi monkeytooth, If you break your time string down into its relevant parts, you could then use mktime() to convert it into a UNIX timestamp. i.e. mktime($hour, $minute, $second, $month, $day, $year) You could use the strtotime() also but would have to format the string correctly (US English date format). So that again would require you break the string down into its relevant parts. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/175101-timestamp-conversion-rss-to-unix/#findComment-922884 Share on other sites More sharing options...
thebadbad Posted September 22, 2009 Share Posted September 22, 2009 The reason I posted strtotime() was that I tested it and found it to work. It supports other formats than the standard YYYY-MM-DD HH:MM:SS. <?php $date = 'Tue, 22 Sep 2009 04:00:40 GMT'; $stamp = strtotime($date); //check timestamp by reverting the operation echo gmdate('D, j M Y H:i:s T', $stamp); //Tue, 22 Sep 2009 04:00:40 GMT ?> Link to comment https://forums.phpfreaks.com/topic/175101-timestamp-conversion-rss-to-unix/#findComment-922900 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.