Skip to content

Instantly share code, notes, and snippets.

@connortreacy
Last active December 30, 2015 09:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save connortreacy/7807945 to your computer and use it in GitHub Desktop.
Save connortreacy/7807945 to your computer and use it in GitHub Desktop.
Function for 'parsing' a datestamp in the format returned by Parse for the createdAt / updatedAt fields. Written in JavaScript, but the regex is portable.
var parseDate = function(parseDateString) {
var pattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).(\d+)Z$/g;
var match = pattern.exec(parseDateString);
var date = new Date(match[1],parseInt(match[2])-1,match[3]-1,match[4],match[5],match[6],match[7]);
return date;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment