ISO 8601 Duration Converter

Convert ISO 8601 duration notation (e.g. PT1H30M) to and from total seconds. Handy for decoding formats used by the YouTube API, AWS timeout settings, and podcast RSS feeds.

Common ISO 8601 Duration Examples

An ISO 8601 duration starts with "P", followed by years/months/days, then "T" followed by hours/minutes/seconds. Below are common examples and the seconds they represent.

Notation Total seconds Note
PT30S 30 A typical short timeout value, such as 30 seconds
PT1H30M 5,400 1 hour 30 minutes — a common way to express movie runtimes or YouTube video lengths
P1D 86,400 1 day (24 hours) — often used for log retention periods or cache expiry settings
P3Y6M4DT12H30M5S 110,842,205 A combined example equal to 3 years, 6 months, 4 days, 12 hours, 30 minutes and 5 seconds (years/months use the 365.25-day approximation)

Tips

  • Durations that include years or months don't have a fixed number of seconds in reality, so this tool uses a fixed approximation: 1 year = 365.25 days and 1 month = 30.44 days.
  • When generating a duration string from seconds, choose "days/hours/minutes/seconds only" to avoid the year/month approximation entirely and get an exact, calendar-independent result.
  • The YouTube Data API returns video length in the contentDetails.duration field using ISO 8601 notation, so you can paste it directly here to get the total seconds.
  • Cloud services such as AWS Lambda and API Gateway sometimes use ISO 8601 duration notation for timeout configuration, which makes this tool useful for verifying those settings.
  • Podcast RSS feeds occasionally use ISO 8601 duration format for the itunes:duration tag in addition to the more common hh:mm:ss format.

Frequently Asked Questions

PT1H30M is ISO 8601 duration notation for "1 hour 30 minutes". The "P" marks the start of a period, and "T" marks the start of the time-of-day portion (hours/minutes/seconds) — this matters because without a "T", "1M" means "1 month", while after "T" it means "1 minute".

Well-known examples include YouTube Data API's video length field (contentDetails.duration), timeout and expiry settings in cloud services like AWS and Google Cloud, and podcast RSS feeds (itunes:duration). Many programming languages also support parsing and generating it, such as Java's Duration/Period classes and Python's isodate library.

A year is 365 or 366 days depending on whether it's a leap year, and a month ranges from 28 to 31 days, so there is no single fixed number of seconds for either unit. This tool uses 365.25 days as a practical average for a year (and one-twelfth of that, about 30.44 days, for a month). If you need an exact result, use the "exact" mode, which expresses durations using only days, hours, minutes, and seconds.

Yes, notation like "P2W" (2 weeks) is supported. Note that under the ISO 8601 specification, week notation is a standalone shorthand that cannot be combined with year/month/day or time-of-day components.

If the input doesn't start with "P", the units are out of order (they must follow Y→M→D and, after "T", H→M→S), or every unit is omitted (an empty duration), the tool determines the string cannot be converted and displays an error message instead of a result.
ツールくん

Side Note — Why does the computing world have a dedicated format for "durations"?

ISO 8601 is best known as the international standard for representing calendar dates and times, but the same standard also defines a separate notation for "durations" — the length of time between two points, rather than a single point in time. A date-time answers "when," while a duration answers "how long," and even though the two look similar at a glance, they represent fundamentally different kinds of information. The dedicated "P"-prefixed notation exists precisely to keep that distinction clear.

One reason duration notation is so useful in practice is that it prevents unit-mismatch bugs when data is exchanged between systems. If an API response simply returned the number "30", a caller would have to consult documentation to know whether that meant seconds or minutes. With "PT30S", the value and its unit travel together in a single string, so a correct parser can never misinterpret it.

This is exactly why the YouTube Data API returns video length in ISO 8601 format: a string like "PT4M13S" unambiguously means a 4-minute-13-second video. Cloud platforms such as AWS and Google Cloud sometimes adopt the same format for timeout and expiry settings, so if you spot this notation in a YAML config file or JSON response, running it through this tool to see the equivalent number of seconds can make the value much easier to picture.

At the same time, the standard has an interesting quirk: durations that include years or months don't have a fixed, absolute length. The same "P1Y" can represent 365 or 366 real-world days depending on whether it spans a leap year. Ultimately, this is exactly why this tool has to rely on an approximation whenever a conversion involves years or months.