this post was submitted on 24 Jan 2025
55 points (100.0% liked)
JavaScript
2124 readers
8 users here now
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I'll be very happy to not have to use
Date
any more. Pop quiz, what's inwhatnum
?Err, it's 5... Ha, amazing; that's not even the gotcha I meant to demonstrate.
getDay
returns the day of the week, the day of the month is returned fromgetDate
.Take two:
So this is 14 - 2 = 12, right? Nope! The day (from getDate) is 1-based whereas month is 0-based, so 14 - 1 = 13.
I'm quite lucky because I only had to solve an issue with JavaScript dates once, but what a nightmare it was… I had to understand how timezones worked, that was not fun!