Skip to content

Instantly share code, notes, and snippets.

@cjwinchester
Created April 9, 2014 03:41
Show Gist options
  • Save cjwinchester/10224097 to your computer and use it in GitHub Desktop.
Save cjwinchester/10224097 to your computer and use it in GitHub Desktop.
parse yyyymmdd date objects in javascript
function parse(str) {
var y = str.substr(0,4),
m = str.substr(4,2) - 1,
d = str.substr(6,2);
var D = new Date(y,m,d);
return (D.getFullYear() == y && D.getMonth() == m && D.getDate() == d) ? D : '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment