Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/438.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript .getDay()奇怪的行为_Javascript - Fatal编程技术网

Javascript .getDay()奇怪的行为

Javascript .getDay()奇怪的行为,javascript,Javascript,有一个例子 console.log((new Date(2013, 02, 24)).getDay(), 24) // => 0 24 console.log((new Date(2013, 02, 25)).getDay(), 25) // => 1 25 console.log((new Date(2013, 02, 26)).getDay(), 26) // => 2 26 console.log((new Date(2013, 02, 27)).getDay(), 27

有一个例子

console.log((new Date(2013, 02, 24)).getDay(), 24) // => 0 24
console.log((new Date(2013, 02, 25)).getDay(), 25) // => 1 25
console.log((new Date(2013, 02, 26)).getDay(), 26) // => 2 26
console.log((new Date(2013, 02, 27)).getDay(), 27) // => 3 27
console.log((new Date(2013, 02, 28)).getDay(), 28) // => 4 28
console.log((new Date(2013, 03, 01)).getDay(), 01) // => 1 1
console.log((new Date(2013, 03, 02)).getDay(), 02) // => 2 2
根据,方法
getDay()

根据本地设置返回指定日期的星期几 时间

getDay返回的值是一个整数,对应于日期 星期:0表示星期天,1表示星期一,2表示星期二,依此类推

最后两个结果似乎不是这样。我希望输出如下所示

0 24
1 25
2 26
3 27
4 28
5 1
6 2

我遗漏了什么吗?

设置日期时,超过2表示三月,因为它是以0为基础的。如果您在2月份使用1,它将按预期工作

引用

月份 表示月份的整数值,1月从0开始,12月从11开始