ISO 8601 Duration Converter

Read and write ISO 8601 durations like PT1H30M — in seconds, plain English and back again.

The ISO 8601 Duration Converter runs entirely in your browser. Durations you type are parsed on your device and never uploaded.

Open the Duration Converter

About ISO 8601 Duration Converter

ISO 8601 durations turn up wherever a length of time has to survive a JSON round trip: schema.org video markup, Kubernetes manifests, XML schemas, OpenAPI examples and .NET's round-trip TimeSpan format. The syntax reads P[n]Y[n]M[n]DT[n]H[n]M[n]S, and the detail that catches everyone is M — months before the T, minutes after it, so P1M and PT1M differ by a factor of about 43,000. This converter parses a duration into its fields and totals, builds one from plain text such as "1h 30m" or "1:23:45", and is explicit about the one thing most libraries hide: months and years have no fixed length, so any conversion to seconds rests on an assumption.

Features

How to use the ISO 8601 Duration Converter

  1. Paste an ISO 8601 duration to read it, or switch to build mode
  2. In build mode, type seconds, a clock time or something like 2d 4h
  3. Read the totals, the field breakdown and the plain-English version
  4. Pick a month-length assumption if the duration contains months or years

Example

Input

P3Y6M4DT12H30M5S

Output

3 years, 6 months, 4 days, 12 hours, 30 minutes and 5 seconds
110,984,405 seconds (Gregorian average)

The specification's own example — and a reminder that the two Ms mean different things.

Common errors & troubleshooting

Frequently asked questions

What does PT1H30M mean?
One hour and thirty minutes. P starts the duration, T separates the date part from the time part, and after the T the M stands for minutes rather than months.
What is the difference between P1M and PT1M?
P1M is one month; PT1M is one minute. The T is the only thing distinguishing them, which is why it is not optional even when there is no date part.
How do I convert an ISO 8601 duration to seconds?
Weeks and below are exact — a day is 86,400 seconds. Months and years are not, so a conversion has to assume a length; this tool offers the Gregorian average of 30.44 days and the simpler 30-day figure, and tells you which is in use.
Can an ISO 8601 duration be negative?
The XML Schema profile allows a leading minus, as in -PT30S, and this parser accepts it. Plain ISO 8601 does not define it, so some strict parsers will refuse.
Where are ISO 8601 durations used?
schema.org video and recipe markup, Kubernetes and Prometheus configuration, XML Schema types, OpenAPI examples and .NET's TimeSpan round-trip format, among many others.

Related tools

All ArrayKit tools