Skip to content

Instantly share code, notes, and snippets.

@jcsalterego
Created August 12, 2010 16:28
Show Gist options
  • Save jcsalterego/521236 to your computer and use it in GitHub Desktop.
Save jcsalterego/521236 to your computer and use it in GitHub Desktop.
> now = new Date()
"Thu Aug 12 2010 11:24:42 GMT-0500 (CDT)"
> now.getTime()
1281630282255
> db.foo.drop()
true
> db.foo.insert({datetime:now})
> next = new Date(now.getTime() + 1000)
"Thu Aug 12 2010 11:24:43 GMT-0500 (CDT)"
> db.foo.insert({datetime:next})
> db.foo.find({datetime:{$gt:now}}) // should return 'next'
{ "_id" : ObjectId("4c64208aca1e130036da36a9"), "datetime" : "Thu Aug 12 2010 11:24:43 GMT-0500 (CDT)" }
> db.foo.find({datetime:{$lt:next}}) // should return 'now'
{ "_id" : ObjectId("4c64205dca1e130036da36a8"), "datetime" : "Thu Aug 12 2010 11:24:42 GMT-0500 (CDT)" }
> db.foo.find({datetime:{$gte:now}}) // should return both
{ "_id" : ObjectId("4c64205dca1e130036da36a8"), "datetime" : "Thu Aug 12 2010 11:24:42 GMT-0500 (CDT)" }
{ "_id" : ObjectId("4c64208aca1e130036da36a9"), "datetime" : "Thu Aug 12 2010 11:24:43 GMT-0500 (CDT)" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment