I'm using the twitter API to return a list of status updates and the times they were created. It's returning the creation date in the following format:
Fri Apr 09 12:53:54 +0000 2010
What's the simplest way (with PHP or Javascript) to format this like 09-04-2010?
Today, Twitter IDs are unique 64-bit unsigned integers, which are based on time, instead of being sequential. The full ID is composed of a timestamp, a worker number, and a sequence number.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With