⏳ ISO 8601 Duration Converter
Specify years, months, days, hours, minutes, and seconds to build an ISO 8601 duration string (e.g. P3Y6M4DT12H30M5S), or parse an existing ISO 8601 duration string back into its component parts. Useful for checking durations used in API responses and config files.
How to use
- Choose "build" or "parse" mode.
- In build mode, enter years/months/days/hours/minutes/seconds; in parse mode, enter an ISO 8601 duration string.
- The result is shown automatically.
How the calculation works
An ISO 8601 duration expresses a length of time as a string that starts with “P” and lists years, months, weeks, days, hours, minutes and seconds with letters. P: start of the period Y years, M months, W weeks, D days T: start of the time part H hours, M minutes, S seconds The same “M” means months before the T and minutes after it. This tool can build a duration from its parts or parse a duration into its parts. Weeks (P2W) are shown as days (14 days). Seconds may have a fraction, with either a full stop or a comma as the decimal sign. The total in seconds is an estimate that treats a month as 30.44 days and a year as 365.25 days on average.
Worked example
P3Y6M4DT12H30M5S → 3 years 6 months 4 days 12 hours 30 minutes 5 seconds (about 110,842,205 seconds in total) PT1H30M → 1 hour 30 minutes (5400 seconds) P2W → 14 days (1,209,600 seconds) PT0,5S → 0.5 seconds Build: 1 day 2 hours 30 minutes → P1DT2H30M Strings with nothing after the T, such as “PT” or “P1DT”, are invalid under the standard and are rejected.
Things to be aware of
- The YouTube API returns video lengths like PT4M13S. The format also appears in program settings and in iCalendar repeat intervals.
- Months and years vary in length, so check how your software handles P1M when converting it to seconds or adding it to a date.
- Zero parts can be left out. A zero duration is written PT0S.
FAQ
What is an ISO 8601 duration string?
An international standard notation starting with "P", followed by years (Y), months (M), and days (D), then a "T" separator followed by hours (H), minutes (M), and seconds (S). For example, "P3Y6M4DT12H30M5S" means 3 years, 6 months, 4 days, 12 hours, 30 minutes, and 5 seconds.
How is total seconds calculated?
It approximates a month as 30.44 days (365.25 ÷ 12) and a year as 365.25 days. Since calendar months and leap years vary in length, this is only an approximation.
Where is this format used?
REST API responses, iCalendar files, the XML Schema duration type, and many other standards and config formats use this notation for durations.