Last active
December 16, 2015 17:09
-
-
Save jgable/5468402 to your computer and use it in GitHub Desktop.
Walltime Conversion between time zones
This file contains 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
var rightNow = new Date(), | |
chicagoWallTime = WallTime.UTCToWallTime(rightNow, "America/Chicago"), | |
osloWallTime = WallTime.UTCToWallTime(rightNow, "Europe/Oslo"), | |
backToUTCTime = WallTime.WallTimeToUTC("America/Chicago", chicagoWallTime); | |
var formatWallTime = function(wt) { | |
// Format a walltime; 4/26/2013 9:21:13 | |
return [wt.getMonth(), wt.getDate(), wt.getFullYear()].join("/") + " " + [wt.getHours(), wt.getMinutes(), wt.getSeconds()].join(":"); | |
}; | |
console.log("WallTime in Chicago: ", formatWallTime(chicagoWallTime)); | |
console.log("WallTime in Oslo: ", formatWallTime(osloWallTime)); | |
console.log("WallTime in UTC: ", formatWallTime(backToUTCTime)); | |
console.log("BrowserTime: ", formatWallTime(rightNow)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment