moment: .zone() always returns the local zone
If I create a moment such as:
var m = moment("2013-01-01T00:00:00-04:00");
And then look at the zone:
var z = m.zone();
I would expect to always get back -240, because I created it with the specific -4:00 offset.
Instead, I always get back 420. I am in UTC-7 (Arizona), so this is coming from my local clock.
Even that seems wrong though, because I would expect -420. This seems to be a direct passthrough to getTimezoneOffset(), which also exhibits this behavior. I expect more from moment.js.
It seems that as soon as you create a moment with an offset, that offset is applied and then lost. Is that correct?
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 19 (12 by maintainers)
I’m having the same issue as well, and adding a
zone()
setter would make my life a lot easier.I think I’m having the same issue as @mj1856 with moment.js on my own project. I supply a source string to moment that is carefully crafted with the offset that I want to end up displaying to the user. (My app absolutely needs to show times that are not necessarily in the same timezone as the user’s browser timezone offset setting.)
No matter how I try, I can’t get moment to show me the desired time – I am limited (perhaps by design, according to this thread) to only showing the local time or UTC. Both options are unacceptable for my current application.
Going to try to do a workaround and/or supply a patch, but in the meantime wanted to chime in to let you know that this is a big obstacle.