How to Use This Tool
Paste a duration to break it into parts, or use the builder to produce one. You will see the conversion to seconds where it is defined, and a clear note where it is not.
The T is load-bearing
An ISO 8601 duration starts with P and splits into a date part and a time part, separated
by T. Before the T the letters are Y, M, W and D — years, months, weeks, days. After
it they are H, M and S — hours, minutes, seconds.
M appears in both halves with different meanings. P1M is one month;
PT1M is one minute. There is roughly a forty-thousand-fold difference between them and the
only thing distinguishing the two strings is one character. Omitting the T when you meant minutes is the
single most common mistake with this format.
Why months and years cannot be converted to seconds
The time part converts cleanly: an hour is always 3,600 seconds. The date part does not, and this is a genuine property of calendars rather than a limitation of the tool.
- A month is 28, 29, 30 or 31 days depending on which month and which year.
- A year is 365 or 366 days.
- A day is usually 86,400 seconds, but 23 or 25 hours long on the days a timezone changes for daylight saving.
So P1M has no length until you say from when. One month from 31 January is not
a fixed number of seconds, and different libraries disagree about what it even means. This tool converts
the time part exactly and reports the date part as calendar units, rather than multiplying by an average
month and presenting the result as if it were precise.
Where you meet this format
The YouTube Data API returns video lengths as ISO durations, which is why PT1H30M turns
up in so many search results — people are trying to turn PT4M13S into 4:13. It is also
used by Kubernetes, several CI systems, XML Schema, and anything speaking the OData or Atom family of
formats. If you are converting YouTube durations, note that only H, M and S appear there, so the seconds
conversion is always exact.
Details worth knowing
- Weeks stand alone.
P1Wis valid, but the standard does not allow combining W with other date components, soP1W2Dis not strictly legal even though many parsers accept it. - Only the last component may be fractional.
PT0.5Sis fine;PT0.5H30Mis not. - Zero needs a component. A bare
Pis invalid; zero is writtenPT0S. - Durations are not timestamps.
P1Dsays "one day long", not "1 January". A period between two fixed dates uses a different notation with a slash.
