ISO 8601 duration parser
ISO 8601 durations show up in APIs, video metadata, calendars and schedules. Paste one to see its parts and its length in seconds, minutes, hours and days, or enter a number of seconds to get the matching duration string.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Type or paste a duration such as
PT1H30M into the first box. The parts and totals appear at once.
- To go the other way, clear the first box and enter a number of seconds. The tool writes the duration string.
How it works
A duration is P, then optional years, months, weeks and days, then an optional T followed by hours, minutes and seconds. Each part is a number and a letter. The total is years × 365 × 86 400 + months × 30 × 86 400 + weeks × 604 800 + days × 86 400 + hours × 3 600 + minutes × 60 + seconds.
Worked examples
PT1H30M is 1 × 3 600 + 30 × 60 = 5 400 seconds.
P3Y6M is (3 × 365 + 6 × 30) = 1 275 days, which is 110 160 000 seconds under the 365 and 30 day convention.
P2W is 14 days, or 1 209 600 seconds.
- 90 061 seconds is 1 day, 1 hour, 1 minute and 1 second:
P1DT1H1M1S.
Good to know
Some systems accept only part of the standard. Weeks, for example, are often not allowed together with other parts, while this tool accepts them alongside years, months and days in the order the standard writes them.
Frequently asked questions
What does the T in an ISO 8601 duration mean?
The T separates the date part from the time part. M means months before the T and minutes after it, so P1M is one month and PT1M is one minute.
How long is P1M or P1Y in seconds?
It depends on the calendar date, so there is no single answer. This tool uses a fixed convention of 365 days for a year and 30 days for a month, and says so when months or years are present. Days, hours, minutes and weeks are exact.
Can a duration have a fraction?
Yes, but ISO 8601 allows a decimal fraction only on the smallest part, as in PT0.5S or P1.5D. A comma works as the decimal mark too.
Why does the reverse conversion never use months or years?
A number of seconds does not say which calendar months it spans, so the result uses days as the largest unit. 90061 seconds becomes P1DT1H1M1S.