Skip to content

Instantly share code, notes, and snippets.

@pianosnake
Created January 13, 2014 22:25
Show Gist options
  • Save pianosnake/8409307 to your computer and use it in GitHub Desktop.
Save pianosnake/8409307 to your computer and use it in GitHub Desktop.
Get date from Mongo ID
function mongoDate(mongoId){
var timehex = mongoId.substring(0,8);
var secondsSinceEpoch = parseInt(timehex, 16);
return new Date(secondsSinceEpoch * 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment