ForHosting KIT · Dates & time

Days in a month calculator

February 2024 has 29 days, because 2024 is a leap year. Enter a year and a month from 1 to 12 to get the exact number of days, the month's name and whether the year is a leap year. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Year
2,024
Month
2
You get
Month name
February
Days
29
Calendar
gregorian

Knowing how many days sit in a calendar month is a small question with sharp edges: February changes in leap years, and a wrong length breaks billing cycles, schedule builders, and form validation. This days in a month calculator applies the Gregorian rules deterministically—month lengths for January through December plus the standard leap-year test for February—so you get an exact integer without guessing or consulting a wall calendar. Invalid months outside one through twelve fail with a clear invalid input error and are not charged.

Why February is the only month that changes

Every month except February has a fixed length of thirty or thirty-one days in the civil calendar, so only February depends on the year. Under the Gregorian rule a year is a leap year when it is divisible by four, except century years, which must also be divisible by four hundred. That is why 2000 had a 29-day February while 1900 had only 28, and why 2024 is a leap year. Enter the year and the month number, from 1 for January to 12 for December, and the calculator returns the exact count, the month's name and whether the whole year is a leap year.

Where an exact month length matters

A wrong month length quietly breaks things. Date pickers use it to set the last day someone can choose, so nobody ends up picking 30 February, and they update on their own when the year turns out to be a leap year. Billing and subscription systems need it to work out each calendar-month period, and scheduling and payroll tools rely on it to build monthly windows and checks. A month outside 1 to 12 is rejected rather than guessed, so a typing mistake shows up at once instead of producing a silent wrong length.

Year, month, and the Gregorian leap-year rule

Provide two integers: year in the supported Gregorian range, and month as one for January through twelve for December. Common months always have thirty-one or thirty days according to the fixed civil calendar table; February alone depends on the year. Under the Gregorian leap-year rule a year is a leap year when it is divisible by four, except that century years must also be divisible by four hundred.

That is why the year two thousand has a twenty-nine-day February while nineteen hundred has twenty-eight, and why twenty twenty-four is a leap year but twenty twenty-three is not.

Form and UI date pickers

Front ends set the maximum day of the month from year and month so users cannot pick February 30, updating automatically when the year becomes a leap year.

Billing and subscription periods

Billing engines compute period length for a calendar month without reimplementing leap rules in every language or service.

Scheduling and payroll windows

Schedulers and payroll tools derive how many days fall in a given month when building monthly windows and validation checks.

What happens if the month is outside 1 to 12?

Months must be integers from 1 (January) through 12 (December); values outside that range are rejected and not charged.

How are leap years decided?

The Gregorian rule: divisible by 4, except century years must also be divisible by 400. So 2000 is a leap year, 1900 is not, and February has 29 or 28 days accordingly.

Is the days in a month calculator free?

The browser tool runs free on your device.

Why does the result say whether the year is leap even for other months?

Because leap status belongs to the whole year, not just to February. A calendar or dashboard can then show one leap-year badge for the year without asking again for each month.

How many days can a month have?

Anywhere from 28 days up to thirty-one. Every month except February has a fixed length of thirty or thirty-one days, while February has 28 days in a common year and 29 in a leap year.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/date/days-in-month

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/date/days-in-month \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"year":2024,"month":2}'
{
  "year": 2024,
  "month": 2
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "date.days_in_month",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Send a year and a month from one to twelve; the response returns the day count, the English month name, whether the year is a leap year, and a stable method label for pipelines.

Year, month, and the Gregorian leap-year rule

Aliases y and yr for year, and m and mon for month, are accepted when documented. Missing fields, non-integers, years outside the published bounds, and any month less than one or greater than twelve raise invalid_input so callers can fix the request instead of receiving a silent wrong length.

Reading the response: days, month name, and leap flag

On success the response echoes the normalized year and month, a month_name string in English for display (for example February), and days as the integer length of that month—twenty-eight through thirty-one. The is_leap_year boolean reports whether the year itself is a Gregorian leap year, even when the requested month is not February, so dashboards can show a single leap badge for the whole year without a second call. The calendar field is always gregorian and method is always days_in_month, which lets routers and tests branch on labels rather than sniffing shapes. Use days alone when you only need the length for range checks; use month_name when building human-readable summaries; combine days with is_leap_year when generating February-aware UI copy. Validation failures never consume prepaid balance after the engine rejects the payload, matching other KIT parse capabilities.

API usage, pricing, workflows, and practical limits

Call the free in-browser days in a month calculator for homework checks, product demos, and quick verification without installing calendar libraries. Keep months strictly in one through twelve—the product contract rejects out-of-range months rather than rolling them over—so clients surface bad form values early. Year bounds follow the published parameter range for isolate safety and common civil use. Send a JSON body with required integer fields year and month. Use the prepaid API when a billing platform, scheduling service, payroll tool, or form validator needs a stable contract under KIT balance at $0.002 per successful item. Pair this endpoint with business-day counters when the next step is weekdays only, or with date formatters when you need localized display after you already know the month length. Authors shipping SDKs can map the days field into max attributes on day selectors and show is_leap_year next to February labels in the same response.

How do I get the number of days in a month?

Send JSON with year and month (1–12), for example year: 2024 and month: 2. The response includes days (29 for that leap February), month_name, and is_leap_year.

Does it use the system Date object?

No. Day counts are computed with pure integer arithmetic so results are deterministic across time zones and hosts, and golden tests stay stable.

Read the full KIT documentation →