Question

So I am currently in the "America/Los_Angeles" timezone (PDT), but when I create a new moment object and pass it through moment tz to set its timezone to the very one I'm in ('America/Los_Angeles'), like so:

moment().tz("America/Los_Angeles");

the wrong time is being returned. Specifically, it's 8 hours ahead. This happens for all other timezones I try as well.

Am I just fundamentally misunderstanding how this is supposed to work?

Thanks for any help!

Était-ce utile?

La solution

When I replaced your copy of moment-timezone.js with the one from the web site, it returned the correct result.

Autres conseils

You need to use "zone" you pass it an offset off GMT.

moment().zone(-8)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top