Skip to content

Instantly share code, notes, and snippets.

@akirattii
Last active October 26, 2016 22:54
Show Gist options
  • Save akirattii/6eb6bee87a656ed3dda306888ceefffe to your computer and use it in GitHub Desktop.
Save akirattii/6eb6bee87a656ed3dda306888ceefffe to your computer and use it in GitHub Desktop.
How to set locale (timezone) using moment-timezone.js
var moment = require('moment-timezone');
// All timezone? See: node_modules/moment-timezone/data/meta/latest.json
let d = moment().tz('Asia/Tokyo').format(); // 2016-10-27T07:31:29+09:00
// let d = moment("2016-09-15 23:59:59").tz('America/Phoenix').format(); // 2016-09-15T07:59:59-07:00
// let d = moment().tz('America/Phoenix').format(); // 2016-10-26T15:31:16-07:00
console.log(d);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment