duration

How long is that, really?

Turn a number of seconds into years, months, days and clock time — or parse an ISO 8601 duration back into seconds.

duration converter

no timezone involved
Try

// years and months are averages

A duration is not a date, so there is no calendar to count against. Years here are 365.25 days and months are 30.4375 days — the same convention as most timestamp converters.

// iso 8601

P1Y2M3DT4H5M6S means 1 year, 2 months, 3 days, 4 hours, 5 minutes, 6 seconds. PT45S is 45 seconds; P2W is two weeks. The T separates date units from time units.

Why seconds are not enough

Timeouts, cache lifetimes and token expiries are usually written in seconds. Humans read them in days and hours. The conversion is simple arithmetic, but the interesting part is deciding what a month means: 30 days, 30.437 days, or “the same day next month”.

This page uses fixed averages, which is what you want for a duration. If you need calendar arithmetic — “three months from January 31” — use the date calculator, where months clamp to the length of the target month and daylight saving is resolved through the timezone.

advertisement