令我惊讶的是 new Date().getTimezoneOffset()
返回与 moment().utcOffset()
相反的内容
示例:
- 时区 UTC +08:00 香港
- JS:-480
- 时刻:480
- 时区 UTC -06:00 中美洲
- JS:360
- 时刻:-360
- 时区 UTC 伦敦
- JS:0
- 时刻:-0
问题:
如果我是正确的,momentjs 将返回正确的值。那么为什么 Javascript new Date().getTimezoneOffset()
返回相反的时区偏移量呢?
最佳答案
The time-zone offset is the difference, in minutes, between UTC and local time. Note that this means that the offset is positive if the local timezone is behind UTC and negative if it is ahead. For example, if your time zone is UTC+10 (Australian Eastern Standard Time), -600 will be returned.
关于Javascript getTimezoneOffset 与时刻 utcOffset,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33890898/