Find how many days are in any month

Return the Gregorian month length for a month and the year that controls February.

freeworks offlinenothing uploaded
ToolDays in Month
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

A bare month number, YYYY-MM value, or parsed date selects a month and year, and day zero of the following month supplies its last day number. A bare 1–12 month uses the selected year or the current browser year.

  • Year zero is only a sentinel meaning current year for bare month input.
  • YYYY-MM is preferable whenever February must be reproducible.

Worked example

February in Leap Year
Check how many days February has in a leap year
Input
											2024-02
										
Output
												February 2024: 29 days
											

When to use this

Billing forms choose a final valid date, date pickers size their day menu, and leap-year tests verify February.

Edge cases

  • February 2000 has 29 days because 2000 divides by 400, while February 1900 has 28.
  • A bare 2 can change with the selected or current year; 2024-02 cannot.
  • A month outside 1–12 is rejected instead of rolling into another year.

References