Skip to content
Discussion options

You must be logged in to vote

The Date month argument and getMonth() are 0-indexed: January is 0 and December is 11. So new Date(2026, 5, 1) is June, not May, and getMonth() returns 5 for June. Days of the month (and getDate) are 1-indexed, which makes the inconsistency easy to trip over — add 1 when displaying, or use a date library / Intl.DateTimeFormat.

Replies: 1 comment

Comment options

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