Skip to content

Instantly share code, notes, and snippets.

@comerford
Created December 18, 2014 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save comerford/dfa733ac46d564cb2580 to your computer and use it in GitHub Desktop.
Save comerford/dfa733ac46d564cb2580 to your computer and use it in GitHub Desktop.
Testing ObjectId Snippet
// start a mongo shell to act as a JS interpreter (no db connection required)
mongo --nodb
// store sample id in a variable
var id = new ObjectId("533bc0f60015a0a814000001");
// print out the variable
> id
ObjectId("533bc0f60015a0a814000001")
// try some methods
id.getTimestamp()
ISODate("2014-04-02T07:49:10Z")
id.getTimestamp().getTime()
1396424950000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment