-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Description
nodejs -v : v24.5.0
OS: Debian 12
When set month to 1 - date object returns 2
const tables = [ { month: 0 }, { month: 0 }, { month: 0 }, { month: 0 }, { month: 0 }, { month: 0 }, { month: 0 }, { month: 1 }, { month: 1 }, { month: 1 }, { month: 1 }, { month: 1 }, { month: 1 }, { month: 1 }, { month: 2 }, { month: 2 }, { month: 2 }, { month: 2 }, { month: 2 }, { month: 2 }, { month: 2 }, ]; tables.forEach(tbl => { console.log(tbl.month); const d = new Date(); d.setMonth(tbl.month); console.log(tbl.month,' => ',d.getMonth()); });
this code returns
0
0 => 0
0
0 => 0
0
0 => 0
0
0 => 0
0
0 => 0
0
0 => 0
0
0 => 0
1
1 => 2
1
1 => 2
1
1 => 2
1
1 => 2
1
1 => 2
1
1 => 2
1
1 => 2
2
2 => 2
2
2 => 2
2
2 => 2
2
2 => 2
2
2 => 2
2
2 => 2
2
2 => 2