How to use the iso 8601 duration converter
- Paste ISO 8601 durations such as PT1H30M, one per line. Plain numbers are read as seconds.
- Leave Convert on Detect each line, or force ISO to length or Seconds to ISO.
- Choose the unit to show the length in, and set the days in a year and days in a month for durations that use years or months. In seconds to ISO mode, choose whether 24 hours become a day.
- Read each line as the ISO text, its length and the plain words. Lines with problems are named in the notes. Copy or download the results.
How a duration is written
An ISO 8601 duration starts with P. After it come years (Y), months (M), weeks (W) and days (D), then a T and any hours (H), minutes (M) and seconds (S). The T separates the date part from the time part, which is why M can mean months before the T and minutes after it. Only the parts that are needed are written, so PT45S is 45 seconds and P2W is two weeks. Seconds may have a decimal part, such as PT0.5S.
The page checks that the parts come in order, that a trailing T is not left empty, and that at least one part is present. A line that breaks a rule is named with the reason, such as the order of the parts or a missing P.
Seconds, and the problem with years and months
Weeks, days, hours, minutes and seconds have fixed lengths, so PT1H30M is exactly 5,400 seconds and P1DT12H is 129,600. Years and months do not. A year is 365 or 366 days and a month is 28 to 31, so a length in seconds needs a choice. The page uses the day counts you set, with 365 and 30 as the starting values, which makes P1Y2M3DT4H5M6S equal 36,993,906 seconds. Change the values to match your use, such as 365.25 for an average year.
In the other direction, a number of seconds becomes a duration of days, hours, minutes and seconds only, so 93,784 seconds is P1DT2H3M4S, or PT26H3M4S if you turn off days. Zero is written PT0S. These durations are used in video metadata, calendars, APIs and schema markup, where a length such as a recipe time or a media length is written this way. The page shows the plain words too, like 1 hour 30 minutes, so you can check the reading.
Related tools and privacy
To find the duration between two clock times, use the Time Duration Calculator, and to turn hours and minutes into decimals for pay or billing, the Decimal Hours Calculator. The Unix Timestamp Converter handles points in time rather than lengths. Everything runs in your browser and nothing is uploaded.
Assumptions and limits
- Durations follow the ISO 8601 pattern with years, months, weeks, days and time parts in order. A leading minus sign is not accepted.
- Years and months use the day counts you set, which default to 365 and 30.
- Plain numbers are seconds, up to 1,000,000,000,000, with at most three decimals. Up to 2,000 lines are read.
- Nothing is uploaded or stored.
Frequently asked questions
What does PT1H30M mean?
It is a duration of one hour and thirty minutes, which is 5,400 seconds. P starts every duration, T starts the time part, H is hours and M after the T is minutes.
How do I convert seconds to an ISO 8601 duration?
Paste the number of seconds. 5,400 becomes PT1H30M and 93,784 becomes P1DT2H3M4S. Turn off Use days to get PT26H3M4S for the second.
Why does a year have no fixed number of seconds?
Because years and months vary in length. The page converts them with the day counts you choose, 365 days a year and 30 days a month to start, and says so in the notes.
What is the difference between M before and after the T?
Before the T, M means months. After the T, M means minutes. P1M is a month and PT1M is a minute, which is why the T matters.