Duration

Duration Calculator

Measure the days between two dates, decompose any duration into its standard forms, or shift a date forward or back by a duration.

Awaiting valid inputPick a start and end date, then click Convert.

Accepts plain numbers and tokenised strings (1y 2mo 3d 4h). Months and years use the Gregorian average (30.44d / 365.2425d).

Breakdown
1 day, 2 hours, 30 minutes
95,400 seconds total.
Totals
Years (avg)0.003
Months (avg)0.036
Weeks0.158
Days1.1042
Hours26.5
Minutes1,590
Seconds95,400
Standard forms
ISO 8601P1DT2H30M
Milliseconds95,400,000
Microseconds95,400,000,000
Human1 day, 2 hours, 30 minutes
Awaiting valid inputPick a start date and a duration to add or subtract.

Common durations

Click any to drop it into the Breakdown tab.

What this duration calculator does

The Duration Calculator answers three different 'how long' questions in one place. Between two dates measures the days separating any two calendar dates, with optional checkboxes to count one or both endpoints — useful for contract terms, project plans, or 'how many days since' lookups. Breakdown decomposes a free-form duration like '1 year 2 months 3 days' or a plain number of seconds into every standard unit, plus its ISO 8601 form. Add / Subtract shifts a starting date forward or backward by a duration and reports the resulting calendar date, weekday, Unix timestamp, and day-of-year.

How many days between two dates — the math

Between mode treats both inputs as UTC midnight, so the count is (end − start) / 86,400,000 milliseconds — always an integer. UTC keeps timezones out of the picture: a 'day' is 24 hours regardless of where the user sits or whether daylight saving is in effect. The two 'Include' checkboxes each add one day to the displayed total. With neither checked, 'Jan 1 → Jan 5' reports 4 days (the gap between midnights). Checking 'Include end date' makes it 5; checking both shows 6 (counting Jan 1 plus Jan 2 through Jan 5).

Calendar breakdown vs averaged totals

The result panel shows the same duration in two complementary forms. The calendar breakdown walks the actual calendar — '1 year, 2 months, 3 days' is what you would write on an anniversary card. The averaged totals divide elapsed seconds by Gregorian averages (365.2425 days per year, 30.437 days per month), giving a single comparable number like '1.18 years' or '61 weeks' that is safe to put in a spreadsheet. Both views appear side by side so you do not have to choose; pick whichever matches the question you are answering.

Parsing free-form durations

The Breakdown tab accepts three input shapes. Plain numbers like 90 use the dropdown's default unit (minutes, hours, days, or weeks) — so 90 with the minutes default means 5,400 seconds. Tokenised strings like 1d 2h 30m or 1y 2mo 3d 4h sum every matched token, accepting ms, s, m/min, h/hr, d, w, mo (months), and y (years). Months and years use the Gregorian average so they round-trip cleanly. Anything the parser cannot match returns a 'Can't parse that' hint — see the placeholder for valid examples.

Shifting a date forward or backward

The Add / Subtract tab takes a starting date, a + or operation, and a duration expressed in the same flexible format as Breakdown. It reports the resulting calendar date, its weekday, its Unix timestamp in seconds, and its day-of-year. Useful for scheduling ('release 90 days from now'), contract end-date calculation, conference countdowns, or any time you need to project a date rather than measure between two of them. The 'Duration applied' column also surfaces the ISO 8601 representation and total seconds, so the result is auditable.

Common durations and where they come from

The 'Common durations' strip below the converter lists the eight reference values that come up most often in real work: 1 minute (60 s), 1 hour (3,600 s), 1 day (86,400 s), 1 week (604,800 s), 30 days (2,592,000 s), 1 month at the Gregorian average (2,629,746 s), 1 year at the Gregorian average (31,556,952 s), and 1 calendar year of exactly 365 days (31,536,000 s). Clicking any cell drops that seconds value straight into the Breakdown tab so you can see how it decomposes. The Gregorian-average month and year are the values used everywhere the tool must pick a single number for an inherently variable interval.

Working with the result programmatically

Need to embed this math in code? Every figure on the page is reproducible with two operations: parse the inputs into Unix milliseconds, then subtract or add. For Between mode that is (endMs - startMs) / 86,400,000 for total days. For Add / Subtract it is baseMs + offsetSeconds * 1000. For Breakdown the same parseDurationInput parser used here is available in src/timeUtils.ts of the open-source repository — same regex, same multipliers. ISO 8601 strings come back via the iso8601Duration(seconds) helper for serialising into APIs.

FAQ

How many days are between two dates?
Compute (end_epoch_ms − start_epoch_ms) / 86,400,000. The tool reports this as both an unrounded float and a calendar-breakdown 'X years, Y months, Z days'. Both endpoints can be in different timezones; the underlying math runs in UTC.
Why does 'months' have decimals?
Months have between 28 and 31 days. The 'Months (avg)' row divides elapsed milliseconds by 365.2425 ÷ 12 days, giving a uniformly comparable number. For exact calendar months, read the 'Months' row in the right-hand Calendar breakdown column.
Does this handle daylight saving time?
Yes. Each endpoint is converted to a UTC instant in its chosen timezone before subtraction, so DST transitions on either side of the interval are accounted for automatically — the calendar breakdown matches what wall-clock arithmetic would produce.