为什么JavaScript Date.getTimezoneOffset()考虑"-05:00"?作为正偏移量? [英] Why does JavaScript Date.getTimezoneOffset() consider "-05:00" as a positive offset?

查看:93
本文介绍了为什么JavaScript Date.getTimezoneOffset()考虑"-05:00"?作为正偏移量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,对于我们来说,时区偏移量为-05:00" 的东部时区("America/New_York")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"?作为正偏移量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆