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 CloudFormation timeouts, and Schema.org structured data.

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)

What Is ISO 8601 Duration Notation?

ISO 8601 duration notation is an international standard for expressing the "length" between two points in time as a single string, such as "P3Y6M4DT12H30M5S". While a date-time points to a specific "when", a duration expresses "how long" — a difference rather than a single instant — which is why a dedicated notation starting with "P" exists separately from timestamp formats.

Developers run into this notation constantly: the YouTube Data API reports video length this way, AWS CloudFormation uses it for timeouts, and Schema.org structured data and iCalendar alarms use it for lengths and offsets. This tool converts between duration strings and total seconds instantly, so you can see exactly how long a value really represents.

How to Convert ISO 8601 Durations and Seconds

  1. Paste a duration string to convert it to seconds Enter an ISO 8601 duration string such as "PT1H30M" into the top text box, and the total seconds and a per-unit breakdown appear automatically.
  2. Try the sample value Click "Insert sample" to load an example that combines years, months, days, hours, minutes, and seconds, so you can see the conversion in action right away.
  3. Enter seconds to convert them to a duration string Type the total number of seconds you want to convert into the bottom text box, and the matching ISO 8601 duration string is generated.
  4. Choose a conversion mode Select "years/months/days" for a compact, readable notation, or "days/hours/minutes/seconds only" for an exact result with no calendar approximation.
  5. Copy the result Copy the displayed total seconds, minutes, hours, or days — or the generated duration string — directly into your API request or config file.

Tips for getting more out of it

  • 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.
  • Timeouts for AWS Lambda, API Gateway and Step Functions are integers in seconds or milliseconds, not ISO 8601 durations. In AWS, duration notation appears in places like CloudFormation's CreationPolicy, and this tool is handy for checking those values.
  • The itunes:duration tag in podcast RSS feeds is written in seconds (or hh:mm:ss), not in ISO 8601 duration notation. This tool helps when you need to turn an ISO 8601 value into seconds before writing it there.

Where ISO 8601 Duration Conversion Comes in Handy

Parsing YouTube Data API responses

Paste a value like "PT4M13S" from contentDetails.duration to instantly see how many minutes and seconds a video runs.

Debugging AWS and cloud service settings

CloudFormation's CreationPolicy (ResourceSignal Timeout) and WaitCondition timeouts are written in ISO 8601 duration notation such as "PT15M", so you can check how many seconds or hours they really mean.

Checking durations in structured data (Schema.org)

Schema.org's duration and recipe cookTime/prepTime use ISO 8601 notation such as "PT1H30M", so you can confirm that the value in your markup is the length you intended.

Working with iCalendar (RFC 5545) alarms and durations

iCalendar's TRIGGER (for example -PT15M) and DURATION properties use ISO 8601-style durations, which you can build backward from a number of seconds. Note that Google Calendar API reminders are given as an integer number of minutes instead.

Building test fixtures for a custom parser

If you are writing your own duration parser, use this tool to verify the correct number of seconds for known duration strings and use them as test expectations.

ISO 8601 Duration Glossary

ISO 8601
An international standard that defines how to represent dates, times, and durations. Besides date notation like "2026-09-16", it also defines the duration notation this tool handles.
Duration
A value representing the length of time between two points. Unlike a date-time, which points to a single moment, a duration carries information about how much time elapses.
PnYnMnDTnHnMnS notation
The basic format of ISO 8601 duration strings: years (Y), months (M), and days (D) after "P", followed by hours (H), minutes (M), and seconds (S) after "T", including only the units that are needed.
Timestamp
A value representing one specific point in time. Unlike a duration (a difference), a timestamp expresses an absolute position — "when" something occurred.
RFC 3339
A specification, based on ISO 8601, for expressing date-times on the internet. Its normative text covers only timestamps; durations appear only in the informative Appendix A, which transcribes the ISO 8601 syntax as ABNF.
Week notation (PnW)
A shorthand like "P2W" that expresses a duration purely in weeks. Under ISO 8601, this standalone form cannot be combined with year/month/day or time-of-day components.

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 the YouTube Data API's video length field (contentDetails.duration), the timeout in AWS CloudFormation's CreationPolicy, Schema.org's duration and cookTime, and iCalendar (RFC 5545) TRIGGER and DURATION values. 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.
Tool-kun

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. Some cloud settings, such as the CreationPolicy timeout in AWS CloudFormation, adopt the same format, 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.