-
I am calling startOfYesterday followed by getMonth and which gives the previous month. For example today it 8/12
If I I just create a date on my own it works
I assume this is bug? |
Beta Was this translation helpful? Give feedback.
Answered by
fturmel
Aug 12, 2021
Replies: 1 comment
-
No bugs, months are 0-based indexes in JavaScript. The index of the month of August is 7 and not 8. console.log(new Date(2021, 7, 11))
// Wed Aug 11 2021 00:00:00 GMT-0400 (Eastern Daylight Time)
console.log(new Date(2021, 8, 11))
// Sat Sep 11 2021 00:00:00 GMT-0400 (Eastern Daylight Time) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tan75
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No bugs, months are 0-based indexes in JavaScript. The index of the month of August is 7 and not 8.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date