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
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.