Oh yeah and that too in UTC timezone, not my local one. Turns out this weird behavior is built into nodejs. Almost every other lang I've worked on gives local time by default, looks like I've got a lot to learn!
I'm not positive it's an array underneath, but either way, months are special (or I guess days are special). First day of the month is 1, first month of the year is 0. It's not consistent which has always bothered me.
I think the difference here is, a day doesn't represent an underlying structure. Both the day of the week and month of the year can be represented as enums and are both zero-based which supports this mentality.
I agree. I've also made the same mistakes. If js had used some kind of interface/enum, it would be more clear, or was consistent with the other "Date" constructs such as day of the month being one-based. Unfortunately, it's way too late now.
247
u/TrikkyMakk May 28 '19
Months are zero based