Javascript getTimezoneOffset 与时刻 utcOffset

Javascript getTimezoneOffset vs moment utcOffset

令我惊讶的是 new Date().getTimezoneOffset() returns 与 moment().utcOffset()

相反

示例:

问题:
如果我是正确的 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.

来自:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset

接受的答案解释了 getTimezoneOffset 的作用,但 Moment.js 文档明确描述了时刻 utcOffset 和日期 getTimezoneOffset 之间的区别。

Note: Unlike moment.fn.zone this function returns the real offset from UTC, not the reverse offset (as returned by Date.prototype.getTimezoneOffset).

来源:https://momentjs.com/docs/#/manipulating/utc-offset/