我完全不明白为什么这不起作用?
我正在遍历日期范围并逐步添加 1 小时。直到本周这一切都很好。基本上直到日期达到 2011 年 3 月 27 日 01:00:00 GMT+0100。然后它只是卡住并且不添加任何东西。如果我添加 +3h 然后它再次工作,但不是 +1。
我在 Firefox 上使用 Firebug,也在控制台中尝试过。
Sun Mar 27 2011 01:00:00 GMT+0100
>>> this.setHours(0);
1301180400000
>>> this.setHours(1);
1301184000000
>>> this.setHours(2);
1301184000000
>>> this.setHours(3);
1301187600000
这是代码:
Date.prototype.addHours = function (h) {
this.setHours(this.getHours() + h);
return this;
}
我在 Safari 和 Chrome 中有同样的错误。
最佳答案
关于Javascript setHours(1) 不适用于 2011 年 3 月 27 日 01 :00:00 GMT+0100,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5391177/