Skip to content

Instantly share code, notes, and snippets.

@magician11
Created March 2, 2018 08:19
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 magician11/79f2136f2ca9962913b0e043dbe8de85 to your computer and use it in GitHub Desktop.
Save magician11/79f2136f2ca9962913b0e043dbe8de85 to your computer and use it in GitHub Desktop.
How to use Node.js to display the time now in a different timezone
const moment = require('moment-timezone'); // https://momentjs.com/timezone/
const timestamp = new Date();
console.log(
moment(timestamp)
.tz('America/Vancouver') // find your zone here https://momentjs.com/timezone/docs/#/data-loading/getting-zone-names/
.format('dddd, MMMM Do YYYY, h:mm:ss a (UTC Z)')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment