为什么MIMST TIMEZONE返回错误的UTCOFFSET
对于一些时区结果,可以给出utcoffset
和moment()
不同,即欧洲/贝尔格莱德
。当前是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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案在这里 https://github.com/moment/moment/moment time-moment time timezone/issues/989 。
而不是
unix()
使用
valueof()
是正确的Answer is here https://github.com/moment/moment-timezone/issues/989.
Instead of
unix()
it is correct to use
valueOf()