Why does JavaScript Date.getTimezoneOffset() consider quot;-05:00quot; as a positive offset?(为什么 JavaScript Date.getTimezoneOffset() 会考虑“-05:00?作为一个积极的抵消?)
问题描述
我注意到,对于我们在东部时区(America/New_York"),时区偏移为 -05:00" Date.getTimezoneOffset() 返回一个正 300 的数量.我预计在 Utc 以西的地区以分钟为单位的偏移量为负数,在 Utc 以东的地区为正数,但显然它是翻转的".这个决定背后的原因是什么?
I noticed that for us on Eastern Time zone ("America/New_York") with timezone offset of "-05:00" Date.getTimezoneOffset() returns a positive number of 300. I would expect offset in minutes to be negative in areas to the West from Utc, and to be positive in areas to the east of Utc, but apparently it's "flippded". What's the reasoning behind that decision?
http://momentjs.com/ 遵循相同的规则并返回...
http://momentjs.com/ follows the same rule and returns...
moment.parseZone("01/13/2014 3:38:00 PM +01:00").zone() // == -60
moment.parseZone("01/13/2014 3:38:00 PM -01:00").zone() // == 60
同时 DateTimePicker http://trentrichardson.com/examples/timepicker/ 在设置它的时候不会翻转数字初始时区"参数.错了吗?
At the same time DateTimePicker http://trentrichardson.com/examples/timepicker/ does not flip numbers when setting its initial 'timezone' parameter. Is it wrong?
推荐答案
因为它是这样定义的.引用文档(MDN):
Because that's how it's defined. Quoting the doc (MDN):
时区偏移量是 UTC 和当地时间.请注意,这意味着 偏移量是正的,如果本地时区落后于 UTC,如果领先则为负数.
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.
这篇关于为什么 JavaScript Date.getTimezoneOffset() 会考虑“-05:00"?作为一个积极的抵消?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 JavaScript Date.getTimezoneOffset() 会考虑“-05:00"?作为一个积极的抵消?
基础教程推荐
- Chart.js 在线性图表上拖动点 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01