Skip to tool
ecech.
🕑 Date, Time & Timezone

ISO 8601 Duration Parser, Where P1M Is a Month and PT1M Is a Minute

The same letter M means month before the T and minute after it. Paste a duration to see the parts, and where a conversion to seconds is genuinely undefined.

In seconds

Human readable

Clock format

h:mm:ss

Parts


Or build one

Result



  
Advertisement

How the calculation works

The same letter, two meanings, decided by the T P1M one month 28 to 31 days, depending on where you start PT1M one minute exactly 60 seconds, always The T is not decoration. It separates the date part from the time part. Roughly a 44,000-fold difference between these two strings.

How to Use This Tool

Paste a duration to break it into parts, or use the builder to produce one. You will see the conversion to seconds where it is defined, and a clear note where it is not.

The T is load-bearing

An ISO 8601 duration starts with P and splits into a date part and a time part, separated by T. Before the T the letters are Y, M, W and D — years, months, weeks, days. After it they are H, M and S — hours, minutes, seconds.

M appears in both halves with different meanings. P1M is one month; PT1M is one minute. There is roughly a forty-thousand-fold difference between them and the only thing distinguishing the two strings is one character. Omitting the T when you meant minutes is the single most common mistake with this format.

Why months and years cannot be converted to seconds

The time part converts cleanly: an hour is always 3,600 seconds. The date part does not, and this is a genuine property of calendars rather than a limitation of the tool.

  • A month is 28, 29, 30 or 31 days depending on which month and which year.
  • A year is 365 or 366 days.
  • A day is usually 86,400 seconds, but 23 or 25 hours long on the days a timezone changes for daylight saving.

So P1M has no length until you say from when. One month from 31 January is not a fixed number of seconds, and different libraries disagree about what it even means. This tool converts the time part exactly and reports the date part as calendar units, rather than multiplying by an average month and presenting the result as if it were precise.

"One month after 31 January" has no single answer 31 Jan + P1M 28 Feb clamp to the last valid day 3 Mar overflow the extra days Both are defensible. Which you get depends on the library, not the standard.
Calendar arithmetic is a choice, which is why a month has no fixed length in seconds.

Where you meet this format

The YouTube Data API returns video lengths as ISO durations, which is why PT1H30M turns up in so many search results — people are trying to turn PT4M13S into 4:13. It is also used by Kubernetes, several CI systems, XML Schema, and anything speaking the OData or Atom family of formats. If you are converting YouTube durations, note that only H, M and S appear there, so the seconds conversion is always exact.

Details worth knowing

  • Weeks stand alone. P1W is valid, but the standard does not allow combining W with other date components, so P1W2D is not strictly legal even though many parsers accept it.
  • Only the last component may be fractional. PT0.5S is fine; PT0.5H30M is not.
  • Zero needs a component. A bare P is invalid; zero is written PT0S.
  • Durations are not timestamps. P1D says "one day long", not "1 January". A period between two fixed dates uses a different notation with a slash.
Advertisement

Frequently Asked Questions

What does PT1H30M mean?
One hour and thirty minutes, or 5,400 seconds. The P marks it as a duration, the T separates the date part from the time part, and H and M after the T are hours and minutes. It is the format the YouTube Data API uses for video lengths.
What is the difference between P1M and PT1M?
P1M is one month and PT1M is one minute. The letter M means month before the T and minute after it, so the T is what distinguishes them. Leaving out the T when you meant minutes is the most common mistake with this format, and it changes the value by roughly a factor of forty thousand.
Why can't an ISO duration with months be converted to seconds?
Because a month is not a fixed length — it is 28, 29, 30 or 31 days depending on which month and year, and a year is 365 or 366 days. A duration containing Y or M only has a length once you attach it to a start date. Converting with an average month would produce a precise-looking number that is wrong for most dates.
How do I convert a YouTube duration like PT4M13S?
Read the components after the T: 4 minutes and 13 seconds, which is 253 seconds or 4:13 in clock format. YouTube durations only ever use H, M and S, so the conversion to seconds is always exact — the ambiguity around months never arises there.
Is P1W2D valid?
Strictly, no. The standard treats weeks as an alternative to the other date components rather than something to combine with them, so P1W is fine and P1W2D is not, even though many parsers accept it. If you need nine days, P9D is unambiguous everywhere.
How do I write a zero duration?
PT0S. A bare P is invalid because a duration needs at least one component, and PT alone is not valid either. PT0S is the conventional way to express no time at all.

Related tools in Date, Time & Timezone

Browse all Date, Time & Timezone tools
The Mac mini the ecech. site is built on, beside a handwritten note reading ecech.com.

Made by one person

ecech. is not a content farm. Every tool here is written and checked by hand, one at a time, by someone who wanted the tool to exist and could not find a version that showed its working.

No accounts and no sign-in, and nothing you type reaches a server — every calculation on this page runs inside your browser. The ads are served by Google and do set their own cookies, which is set out in full on the privacy page. More about the site.