Skip to content

Instantly share code, notes, and snippets.

@tjstebbing
Created September 17, 2014 00:57
Show Gist options
  • Save tjstebbing/9cb995701574420d6777 to your computer and use it in GitHub Desktop.
Save tjstebbing/9cb995701574420d6777 to your computer and use it in GitHub Desktop.
// Watch me get today's Date like a boss..
// In node:
var now = new Date(); // Wed Sep 17 2014 10:51:36 GMT+1000 (EST)
var today = new Date(now.toDateString()); // Wed Sep 17 2014 00:00:00 GMT+1000 (EST)
//Woo! it's still the 17th
//In mongo shell
var now = new Date(); // ISODate("2014-09-17T00:53:28.982Z")
var today = new Date(now.toDateString()); // ISODate("2014-09-16T14:00:00Z")
// WTF??! we've gone back in time, was toDateString being weird?
now.toDateString() // Wed Sep 17 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment