Duration Calculator

Compute a calendar duration between instants or apply one to a date.

  • Runs locally in your browser
  • No upload required

Try it

Fill this to measure a span; leave blank to apply the duration components below.

Mode
span between instants
ISO-8601 duration
P1Y2M3DT4H5M6S
Direction
after
Calendar breakdown
1y 2mo 3d 4h 5m 6s
Total days
427.1702
Total seconds
36907506
Start (UTC)
2026-01-01T00:00:00.000Z
End / result (UTC)
2027-03-04T04:05:06.000Z

Supported formats

Input
text, number
Output
text

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

2024-01-31T00:00:00.000Z to 2024-03-01T00:00:00.000Z is 0 year(s), 1 month(s), 1 day(s), 0:00:00.

How it works

  • Measured the span between the two instants with the later instant as the end.
  • Counted whole calendar years, then whole calendar months with the day clamped to the target month (so Jan 31 + 1 month is Feb 28/29).
  • Counted the remaining whole days, hours, minutes and seconds.
  • The direction reflects whether the end is after or before the start.

Methodology

  1. Parse the start and end (or the applied components) as absolute instants.
  2. For a span, count whole calendar years and months using real month lengths and day-clamping, then the remaining days and time.
  3. For an applied duration, add calendar years and months with day-clamping, then the fixed-length weeks, days and time units.

Time model

  • Time source: an explicit reference supplied by the visitor.
  • Timezone: Instants are absolute and timezone-independent; a date-only input is read as UTC midnight.
  • Locale: ISO-8601 instants and durations only; no locale-specific formatting.
  • Daylight saving: Spans are measured between absolute instants, so daylight-saving transitions never change the result.
  • Reference date: A start instant is required; the end or the applied components are supplied explicitly.

Usage

  1. Enter the start instant.
  2. Enter an end instant to measure the duration, or fill in any duration component to apply it.
  3. Read the calendar breakdown, the totals and the ISO-8601 duration.

Examples

These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.

Across a leap day

jsonSelect to copy
{
  "start": "2024-01-31T00:00:00Z",
  "end": "2024-03-01T00:00:00Z"
}

Across a year boundary

jsonSelect to copy
{
  "start": "2023-01-31T00:00:00Z",
  "end": "2024-03-01T00:00:00Z"
}

Apply one calendar month to Jan 31

jsonSelect to copy
{
  "start": "2024-01-31T00:00:00Z",
  "months": 1
}

Apply a mixed duration

jsonSelect to copy
{
  "start": "2026-01-01T00:00:00Z",
  "years": 1,
  "months": 2,
  "days": 3,
  "hours": 4,
  "minutes": 5,
  "seconds": 6
}

Limitations

Why months are not 30 days

Calendar months have different lengths. This tool advances by whole months using the real calendar and clamps the day, rather than multiplying a fixed 30-day figure.

Frequently asked questions

How is Jan 31 plus one month handled?
The day is clamped to the last valid day of the target month, so Jan 31 plus one month is Feb 29 in a leap year and Feb 28 otherwise.
Does a daylight-saving change affect the result?
No. The calculation is on absolute instants; an hour lost or gained to DST is part of the elapsed span, not a separate correction.

Sources

  1. ISO 8601: Date and time format — ISO