Skip to content

Instantly share code, notes, and snippets.

@JamesHarrison
Created March 27, 2012 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesHarrison/2211855 to your computer and use it in GitHub Desktop.
Save JamesHarrison/2211855 to your computer and use it in GitHub Desktop.
var now = new Date();
var future = new Date(2012, 3, 30, 12);
now.getTime()
1332814128628
future.getTime()
1335783600000
future - now
2969471372
// so far so good, now let's go to seconds from milliseconds
(future - now)/1000
2969471.372
// okay, no surprises. Now take seconds to minutes and then to hours.
(((future - now)/1000)/60)/60
824.8531588888889
// and now we're out by 10. What.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment