- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
令我惊讶的是 new Date().getTimezoneOffset()
返回与 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.
关于Javascript getTimezoneOffset 与时刻 utcOffset,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33890898/
getTimezoneOffset() 方法返回UTC 时间与本地时间之间的时差(以分钟为单位)。 如果我在加利福尼亚州,并且使用的太平洋标准时间,比 (GMT -8) 和 (GMT -7) 晚 8
我知道 Date 对象正在使用机器时区(代码运行的地方)。我有一个特定的用例,需要清除偏移量。 var d = new Date(); console.log(d.getTimezoneOffset(
服务器中存储的日期为 GMT+0,没有夏令时。 客户端应该以自己的时区格式接收它。因此我们可以获取时区偏移量并将其与接收日期进行汇总: const currentTime = new Date();
我有一个函数,可以根据澳大利亚新南威尔士州时区减去本地偏移来计算当前用户位置时间。因此,例如,我想比较澳大利亚 (NSW) 本地时间和我本地时间的事件开始时间,如果我在我的本地主机上打开网站,我会得到
我想知道 Date.prototype.getTimezoneOffset() 如何获取主机系统的时区设置。 据我所知,出于安全原因,浏览器中的 JavaScript 是在沙盒环境中执行的。它如何检索
我的客户端的浏览返回时区偏移值是1020。它有效吗?如果有效,它是什么 Etc/GMT 区?非常感谢。 最佳答案 如果它是 +1020,那么在 UTC 中就是 -17(以前称为 GMT,在 Colle
我电脑的时区是 GMT-7:00 美国和加拿大山区时间。我在 w3cschool 上尝试了一个 javascript 示例: var d=new Date() var gmtHours = -d
我在 Javascript 中的转换逻辑下面有日期时间,它将 UTC 时间转换为传递时区的本地时间。我想知道这个逻辑在日光转换期间是否可以正常工作?如果不是的话有什么补救办法?我无法使用任何第三方库。
有没有办法让这个函数返回时区偏移量并考虑夏令时? 例如,我们位于罗马尼亚,格林威治标准时间(伦敦时间)前 2 小时。但此函数返回 -180(-3 小时)而不是 -120(-2 小时)。 http://
例如我有这个: d = new Date(2013,04,20,14,56,10) Mon May 20 2013 14:56:10 GMT+0800 (SGT) dt = d.getTime() /
更新:请参阅下面的原始帖子。 开始原创帖子 如果用户在聊天时间之外访问该网站,则正在努力将客户的聊天按钮更改为“离线模式”。 工作时间为周一至周五上午 9 点至下午 5 点东部时间(美国时间,而非澳大
在我的浏览器(firefox)中,我执行了这个简单的代码: new Date().getTimezoneOffset(); new Date(1444824485080).getTimezoneOff
我的浏览器在东部标准时区运行,当我调用 date.getTimezoneOffset() 时,我希望返回 -300,但我得到的是 300 var date = new Date(); date.get
令我惊讶的是 new Date().getTimezoneOffset() 返回与 moment().utcOffset() 相反的内容 示例: 时区 UTC +08:00 香港 JS:-480 时刻
Date.getTimezoneOffset 的文档说: Deprecated. As of JDK version 1.1, replaced by -(Calendar.get(Calendar.
documentation似乎建议 getTimezoneOffset() 总是返回当前语言环境的偏移量,而不管日期对象如何。但是我得到的结果不一致,我无法理解。 new Date().getTime
我的代码中的以下行: var timezoneoffset = new Date().getTimezoneOffset(); 返回 -120.14933013916015。 我原以为返回值为 120
我的服务器收到一个 JSON 响应,以秒为单位提供 UTC Unix 时间戳。我将其解析为将在图表中使用的 JavaScript 日期(在用户的语言环境中显示时间)。 我显然必须将我拥有的时间戳(以
我正在尝试将操作系统的 GMT 时间偏移与 Javascript 的 Date.getTimezoneOffset() 的 GMT 时间偏移进行比较。问题是 windows 给出了基于 EST 的偏移
new Date().getTimezoneOffset()*(-1); 此 JS 函数以分钟为单位返回机器的 UTC 时区。有没有PHP函数做同样的事情? 谢谢.. 最佳答案 ACCORDING T
我是一名优秀的程序员,十分优秀!