문제

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!

도움이 되었습니까?

해결책

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

다른 팁

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

moment().zone(-8)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top