Install
npm i moment --save
npm i moment-timezone --save
Use
var moment = require('moment-timezone');
Create moments in and out of DST:
var cdt = moment.tz("2015-07-23 08:30", "America/Chicago");
var cst = moment.tz("2015-11-23 08:30", "America/Chicago");
Check that offset from UTC is what you'd expect:
cdt.tz('America/New_York').format()
> '2015-07-23T09:30:00-04:00'
cst.tz('America/New_York').format()
> '2015-11-23T09:30:00-05:00'
Check that zone aware format output is what you'd expect:
cdt.tz('America/New_York').format('HH:mm:ss')
> '09:30:00'
cst.tz('America/New_York').format('HH:mm:ss')
> '09:30:00'
npm i moment --save
npm i moment-timezone --save
Use
var moment = require('moment-timezone');
Create moments in and out of DST:
var cdt = moment.tz("2015-07-23 08:30", "America/Chicago");
var cst = moment.tz("2015-11-23 08:30", "America/Chicago");
Check that offset from UTC is what you'd expect:
cdt.tz('America/New_York').format()
> '2015-07-23T09:30:00-04:00'
cst.tz('America/New_York').format()
> '2015-11-23T09:30:00-05:00'
Check that zone aware format output is what you'd expect:
cdt.tz('America/New_York').format('HH:mm:ss')
> '09:30:00'
cst.tz('America/New_York').format('HH:mm:ss')
> '09:30:00'