moment-timezone
moment-timezone copied to clipboard
.local() ignoring the default time zone
Consider this code:
moment.tz.setDefault('America/Chicago');
console.log(moment('2016-01-01T00:00:00.000Z'));
console.log(moment.utc('2016-01-01T00:00:00.000Z').local());
I would expect both lines producing the same result, but my actual local time zone is used instead of the default time zone. Output below:
moment.parseZone("2015-12-31T18:00:00.000-06:00")
moment("2016-01-01T01:00:00.000") // wrong time zone
The only workaroud for converting UTC to the default timezone, I've found, is to use moment.utc('2016-01-01T00:00:00.000Z').tz(moment().tz()), but that looks clumsy.
Note that you can create a moment in local mode from UTC-based input (having the Z), which will have the same effect. moment('2016-01-01T00:00:00.000Z')
But yes, it's a bug. Or rather, something we need to consider about what "local" means with respect to changing the default time zone.
See also #258 & #247