When I replaced your copy of moment-timezone.js with the one from the web site, it returned the correct result.
Moment timezone does not return correct time
-
25-06-2023 - |
Вопрос
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!
Решение
Другие советы
You need to use "zone" you pass it an offset off GMT
.
moment().zone(-8)
Не связан с StackOverflow