ISO 8601 Duration Converter

This ISO 8601 duration converter decodes strings like PT1H30M into seconds, minutes, hours and hh:mm:ss, and builds a valid duration back from a number of seconds. It is for developers handling YouTube API video lengths, schema.org cookTime values, calendar feeds and config files, plus anyone who has met P1DT2H in a spreadsheet and wondered what it meant.

Duration decoder
Total seconds
–
Minutes
–
Hours
–
hh:mm:ss
–
s
ISO 8601 duration
–

Runs entirely in your browser — nothing is uploaded. Years and months have no fixed length, so they are converted at a nominal 365 days and 30 days and flagged.

How the ISO 8601 Duration Converter Works

ISO 8601 writes a length of time as a P (for period) followed by numbered parts: Y years, M months, W weeks and D days, then a T and the time parts H hours, M minutes and S seconds. The T matters because M means months before it and minutes after it. The ISO 8601 duration converter matches the string against that pattern, multiplies each part by its length in seconds and adds them up. The builder reverses the process, splitting seconds into days, hours, minutes and seconds and leaving out any zero parts.

Rule: Pattern P[nY][nM][nW][nD][T[nH][nM][nS]], at least one part present. Total seconds = Y × 31,536,000 + M × 2,592,000 + W × 604,800 + D × 86,400 + H × 3,600 + M × 60 + S. Years use a nominal 365 days and months 30 days. Decimals with a dot or comma are accepted on the last part only. hh:mm:ss shows total hours, so a day appears as 24:00:00.

  • ISO 8601 durations — one per line, such as PT4M13S. Lower case is accepted and converted to upper case.
  • Total seconds, Minutes, Hours, hh:mm:ss — the first valid line in four formats.
  • All results (CSV), Copy, Download CSV, Clear — every line with seconds, minutes and clock time.
  • Build a duration from seconds — type seconds to get the matching ISO string, such as 5400 → PT1H30M.

Example Scenarios

InputSecondsMinutesHourshh:mm:ss
PT1H30M5,400901.501:30:00
PT4M13S2534.220.070300:04:13
P1DT2H93,6001,5602626:00:00
PT0.5S0.50.010.000100:00:00.5
P1W604,80010,080168168:00:00
P1Y2M (nominal)36,720,000612,00010,20010200:00:00

ISO 8601 Duration Parser Tips: PT1H30M to Minutes and More

The classic question is PT1H30M to minutes: 1 hour is 60 minutes, plus 30, so 90. Most real-world strings are that simple, but a few details trip up hand-written parsers.

  • Never read M without context. P1M is one month; PT1M is one minute. An ISO 8601 duration parser that ignores the T will be off by a factor of about 43,000.
  • Years and months have no fixed length. ISO duration to seconds is exact only for weeks, days and time parts, and even a day can be 23 or 25 hours across a daylight saving change. For calendar maths, add the duration to a real start date instead.
  • As a youtube duration format converter, this handles the API’s contentDetails.duration values, such as PT4M13S, and longer forms with a day part.
  • Only the smallest part should carry a decimal, so PT1.5H is fine but PT1.5H30M is invalid, and this tool rejects it too.
  • Negative durations are not part of the base standard; some languages accept a leading minus sign, but this tool does not.

In code, Java has java.time.Duration.parse for time-based strings, and libraries such as Luxon cover JavaScript. For quick checks, the ISO 8601 duration converter is faster than writing a test. For the full format, including dates and intervals, see Wikipedia’s ISO 8601 article.

ISO 8601 Duration Converter FAQ

What does PT1H30M mean?PT1H30M is an ISO 8601 duration of 1 hour and 30 minutes. P marks the start of a period, T separates the date parts from the time parts, H is hours and M after the T is minutes. It equals 90 minutes or 5,400 seconds, and the converter shows it as 01:30:00.
How do I convert an ISO 8601 duration in Excel?Excel has no built-in parser for these strings. You can split the text with formulas such as TEXTBEFORE and TEXTAFTER on the H, M and S letters, then add the parts as a fraction of a day. For quick or bulk conversions, paste them here and copy the CSV of seconds back into the sheet.
Can I convert an ISO 8601 duration to a date?A duration is a length, not a moment, so you add it to a start date to get an end date. P1D added to March 1 gives March 2. Months and years need a real calendar for this, because a month can be 28 to 31 days, so use your language’s date library for exact results.
How do I parse an ISO 8601 duration in Java?Use java.time.Duration.parse for strings such as PT1H30M or P2DT3H; it treats a day as exactly 24 hours and returns a Duration you can turn into seconds with getSeconds. For years and months, such as P1Y2M3D, use java.time.Period.parse instead. This converter is handy for checking expected test values.
Is this ISO 8601 duration converter free online?Yes. It is free with no sign-up and runs entirely in your browser, so the durations you paste are never uploaded. Paste many lines at once, read the first one in four formats, then copy or download a CSV with seconds, minutes and hh:mm:ss for every line.
What is the format of YouTube video durations?The YouTube Data API returns video length in ISO 8601 form inside contentDetails.duration, for example PT4M13S for 4 minutes 13 seconds or PT1H2M10S for longer videos. Paste those values here to get seconds or hh:mm:ss, or use the builder to create a matching string from a length in seconds.

Related Tools

Need plain unit conversions? The hours to minutes converter handles quick sums. To add or subtract clock times, use the time calculator for adding durations, and the hours calculator for timesheets totals work hours once the ISO 8601 duration converter has turned API strings into plain numbers.

Related Calculators