Reputation: 1343
For some timezones results that give utcOffset
and moment()
are different, ie for Europe/Belgrade
. Currently it is GMT+2
:
`Now: ${currentMoment.format()}`
// Now: 2022-06-09T12:12:08+03:00
moment.tz.zone("Europe/Belgrade").utcOffset(moment().unix())
// -60 - wrong, 1hr
moment.tz("Europe/Belgrade").format()
// 2022-06-09T11:07:03+02:00 - correct
Upvotes: 0
Views: 357
Reputation: 1343
Answer is here https://github.com/moment/moment-timezone/issues/989.
Instead of unix()
moment.tz.zone("Europe/Belgrade").utcOffset(moment().unix())
it is correct to use valueOf()
moment.tz.zone("Europe/Belgrade").utcOffset(moment().valueOf())
Upvotes: 1