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