Created
March 18, 2014 18:36
-
-
Save Trott/9626471 to your computer and use it in GitHub Desktop.
Timezone-independent countdown. Well, not a countdown, but you know, find out how long it is between now and the specified time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get date object for the current time. | |
var now = new Date(); | |
// Now let's get a timestamp for midnight UTC time. | |
// Well, one millisecond before midnight so we don't have to deal with incrementing. | |
var midnight = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), 23, 59, 59, 999); | |
// And the number of minutes until that time. | |
var diffInMinutes = Math.round((midnight - now.getTime()) / (1000 * 60)); | |
window.console.log("UTC midnight is " + diffInMinutes + " minutes away."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment