gpt4 book ai didi

javascript - .getDay() 奇怪的行为

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:26:01 24 4
gpt4 key购买 nike

<分区>

有一个例子

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

根据 https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getDay , 方法 getDay()

Returns the day of the week for the specified date according to local time.

The value returned by getDay is an integer corresponding to the day of the week: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on.

最后两个结果好像不太对。我希望输出如下所示

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

我错过了什么吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com