Parsing Twitter API Datestamp Parsing Twitter API Datestamp php php

Parsing Twitter API Datestamp


Cross-browser, time-zone-aware parsing via JavaScript:

var s = "Fri Apr 09 12:53:54 +0000 2010";var date = new Date(    s.replace(/^\w+ (\w+) (\d+) ([\d:]+) \+0000 (\d+)$/,        "$1 $2 $4 $3 UTC"));

Tested on IE, Firefox, Safari, Chrome and Opera.


strtotime("dateString"); gets it into the native PHP date format, then you can work with the date() function to get it printed out how you'd like it.


JavaScript can parse that date if you remove the +0000 from the string:

var dStr = "Fri Apr 09 12:53:54 +0000 2010";dStr = dStr.replace("+0000 ", "") + " UTC";var d = new Date(dStr);

Chrome -- and I suspect some other non IE browsers -- can actually parse it with the +0000 present in the string, but you may as well remove it for interoperability.

PHP can parse the date with strtotime:

strtotime("Fri Apr 09 12:53:54 +0000 2010");