我觉得我在这里错过了一些东西。Date.getDay()返回不同的值
Date.getDay()方法应该从0-6返回一个值。星期日为0,星期六为6。
现在我有两个日期,两者都是“星期天”,这应该返回0。
new Date('1990-11-11').getDay() // returns 6
new Date('2016-1-3').getDay() // returns 0
是什么原因造成的差异?我敢于质疑.getDay()
方法的有效性,但我无法弄清楚发生了什么。
编辑
> new Date('1990-11-11')
Sat Nov 10 1990 17:00:00 GMT-0700 (MST)
> new Date('2016-01-03')
Sat Jan 02 2016 17:00:00 GMT-0700 (MST)
> new Date('2016-1-3') // they say this format is wrong, but it returns the right date
Sun Jan 03 2016 00:00:00 GMT-0700 (MST)
我不明白是怎么回事。 1990年1月3日星期日和11月11日是星期天。为什么说星期六?
在我的机器都返回0。 – ppasler
在我的机器也返回0 新的日期(“1990年11月11日”)。getDay()返回新的日期(“2016年1月3日” ).getDay() return 0 – CommonPlane
在我的情况下都返回0。检查这个https://jsfiddle.net/yzyqruyc/ – amulya349