Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.local() ignoring the default time zone #531

Open
bladeSk opened this issue Sep 21, 2017 · 1 comment
Open

.local() ignoring the default time zone #531

bladeSk opened this issue Sep 21, 2017 · 1 comment
Labels

Comments

@bladeSk
Copy link

bladeSk commented Sep 21, 2017

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.

@mattjohnsonpint
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants