Skip to content

getMonth returning wrong value with date generated by startOfYesterday or endOfYesterday #2590

Answered by fturmel
jtshub asked this question in Q&A
Discussion options

You must be logged in to vote

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

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)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tan75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants