Skip to content

Instantly share code, notes, and snippets.

@danro
Created October 18, 2011 20:02
Show Gist options
  • Select an option

  • Save danro/1296539 to your computer and use it in GitHub Desktop.

Select an option

Save danro/1296539 to your computer and use it in GitHub Desktop.
Twitter date string regex replace, IE8 fix
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"));
// Cross-browser, time-zone-aware parsing via JavaScript:
// Tested on IE, Firefox, Safari, Chrome and Opera.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment