ISO 8601 duration converter

What is an Iso 8601 Duration Converter?

ISO 8601 defines a compact text format for durations, such as PT1H30M for one hour and thirty minutes. It is used by the YouTube Data API for video lengths, by schema.org for cooking and event times, by XML Schema, Java's Duration and many calendar systems. This converter turns those strings into seconds and plain English, and converts seconds back into ISO format.

How to use it

  1. Paste an ISO 8601 duration to see the total seconds and a readable description.
  2. Or enter a number of seconds to get the ISO duration string.

The format

P[n]Y[n]M[n]W[n]DT[n]H[n]M[n]S

  • P starts every duration (period).
  • Date part: Y years, M months, W weeks, D days.
  • T separates the time part: H hours, M minutes, S seconds.
  • The same letter M means months before T and minutes after T.

Examples

  • PT90M = 5,400 seconds (1 hour 30 minutes).
  • PT1H30M = 5,400 seconds.
  • P1DT2H30M = 86,400 + 7,200 + 1,800 = 95,400 seconds.
  • PT4M13S = 253 seconds, a typical YouTube video length.
  • P2W = 14 days.

Watch out for

  • Years and months are not fixed lengths. P1M can be 28 to 31 days, so converting it to seconds needs an assumption, commonly 30 days, or a reference date.
  • Days and DST: P1D is usually treated as 24 hours, but a calendar day across a daylight saving change is 23 or 25 hours.
  • Fractions are allowed on the smallest unit, such as PT0.5S.

Frequently Asked Questions

What does PT1H30M mean?

A duration of 1 hour and 30 minutes. P starts the duration and T marks the start of the time part.

How do I tell months from minutes?

M before the T means months, and M after the T means minutes.

How many seconds is P1DT2H30M?

95,400 seconds: one day, two hours and thirty minutes.

Why is converting P1M to seconds ambiguous?

Months have different lengths, so an exact conversion needs a starting date or an assumed month length.