Day zero of the following month falls on the final day of the requested month. Date handles the year rollover for December.
Worked example
console.log(new Date(Date.UTC(2026, 2, 0)).getUTCDate());Result
28Implementation notes
The Date constructor interprets numeric month indexes from zero. Mixing the human-facing month number with that representation is a common source of one-month errors.
Try it yourself
Run the calculation for February in a leap year and a common year.
Open the JavaScript example →Editorial date November 5, 2026 · Published December 6, 2026