Skip to content

Instantly share code, notes, and snippets.

@jgable
Last active December 16, 2015 17:09
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 jgable/5468402 to your computer and use it in GitHub Desktop.
Save jgable/5468402 to your computer and use it in GitHub Desktop.
Walltime Conversion between time zones
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