ISO 8601 Duration Parser & Builder

Decode a duration like PT1H30M into its parts, total seconds and end date — or build one from numbers, seconds or two dates.

Loading tool…

About the ISO 8601 Duration

An ISO 8601 duration starts with P (period), followed by the date units in the order years Y, months M, weeks W, days D; then, after the separator T, the time units hours H, minutes M and seconds S. The T is what tells months from minutes: P1M is one month, PT1M is one minute. Units that are zero are left out, only the last unit may have a decimal fraction (PT0.5S, with a point or a comma), and a duration of nothing is written PT0S. The parser explains exactly what is wrong when a string breaks one of these rules.

Hours, minutes and seconds have a fixed length, and this tool counts a day as 24 hours and a week as 7 days, so PT36H is always 129,600 seconds. Years and months are different: P1M is 28, 29, 30 or 31 days depending on where it starts. That is why the totals for such durations are measured from a start date — years and months are added first, clamping to the end of the month, then the rest — and why the end date is shown next to them. The normalized form carries 60 seconds into a minute, 60 minutes into an hour, 24 hours into a day and 12 months into a year, but never days into months.

Not every library accepts every duration. Java splits the concept in two: Duration is exact time and rejects years, months and weeks, Period is a calendar amount without a time part. Temporal.Duration, Luxon and Moment.js read the full syntax including a leading minus sign, which strict ISO 8601-1 does not have. Mixing weeks with other units (P2W3D) is allowed by ISO 8601-2 and Temporal but not by the original standard, so the tool accepts it with a warning. The YouTube Data API reports video lengths as PT4M13S, or P1DT2H3M4S for videos longer than a day.

How to use it

  1. Type or paste a duration such as PT1H30M, or click one of the examples.
  2. Read the sentence and the components; edit the numbers to build a different duration.
  3. Set the start date to resolve years and months and to see the end date.
  4. Copy the normalized form, the totals or the code for your language.
  5. Use the panels below to convert a number of seconds or the gap between two date-times into a duration.

Frequently asked questions

What does PT1H30M mean?
One hour and thirty minutes: P starts the duration, T starts the time part, 1H is one hour and 30M is thirty minutes. It equals 5,400 seconds and can also be written PT90M or PT1.5H.
What is the difference between P1M and PT1M?
P1M is one month and PT1M is one minute. The letter M means months before the T and minutes after it, so the T is required whenever a duration has hours, minutes or seconds.
How many seconds is P1M or P1Y?
It depends on the start date, because months have 28 to 31 days and years have 365 or 366. From 1 February 2026, P1M is 28 days; from 1 March it is 31 days. Enter the start date to get the exact number.
How do I convert seconds to an ISO 8601 duration?
Divide by 3600 for the hours, the remainder by 60 for the minutes, and keep the rest as seconds: 93,784 seconds is PT26H3M4S, or P1DT2H3M4S when days of 24 hours are used. The “Seconds → duration” panel does this for you.

Related tools