ISO 8601 Duration Calculator
Type an ISO 8601 duration such as P3Y6M4DT12H30M5S or PT36H and see it in plain words, in total seconds and hours, and in its shortest valid form. You can also build a duration from years, months, weeks, days, hours, minutes and seconds, turn a number of seconds into a duration, and add the duration to a date. Everything runs in your browser.
An ISO 8601 duration starts with P, then years (Y), months (M), weeks (W) and days (D), then a T, then hours (H), minutes (M) and seconds (S): P3Y6M4DT12H30M5S is 3 years, 6 months, 4 days, 12 hours, 30 minutes and 5 seconds. The T matters, because M means months before it and minutes after it. Every part is optional but at least one must be present, and only the smallest part may have a decimal fraction. A year or a month has no fixed length, so only durations of weeks and below convert to an exact number of seconds. Adding a duration to a date follows the java.time rule: the months are added first, and a day past the end of the new month moves back to its last day. Dates here have no time zone. Everything is worked out in your browser and nothing is uploaded.
Related Tools
[5 suggestions]Date Calculator
Add or subtract years, months, weeks and days to a date and see the resulting date, its weekday, the day of the year and the ISO week.
Student ToolsDays Between Dates Calculator
Count the days between two dates, with weeks, years, months and days, and the weekdays from Monday to Friday. Option to count the end date.
Student ToolsTime Zone Converter
Convert a date and time from one time zone to many others at once, with daylight saving gaps and repeated hours explained.
Developer & WebUnix Timestamp & Epoch Converter
Convert Unix epoch timestamps to UTC and local dates, or convert human dates to Unix timestamps with auto-detection.
Developer & WebBusiness Days Calculator
Count the working days between two dates, or add or subtract business days from a date, skipping weekends and the holidays you list.
Math & MoneyAbout the ISO 8601 Duration Calculator
An ISO 8601 duration is written P, then the date part in years (Y), months (M), weeks (W) and days (D), then a T, then the time part in hours (H), minutes (M) and seconds (S). P3Y6M4DT12H30M5S means 3 years, 6 months, 4 days, 12 hours, 30 minutes and 5 seconds. The letter T is what separates months from minutes: P1M is one month and PT1M is one minute. Every part is optional, but at least one must be present, and a time part needs at least one amount after the T, so P and PT alone are invalid. The parts must come in order, and only the smallest part may carry a decimal fraction, as in PT0.5S or P0.5D. A leading minus sign makes the duration negative. Durations are used in APIs, calendars, video metadata and schedules, for example the PT4M13S that YouTube-style metadata uses for a 4 minute 13 second video. Only durations of weeks and below have an exact length in seconds, with a day taken as 86,400 seconds, so PT36H is 129,600 seconds. A year and a month have no fixed length, so the total shown for them is an approximation based on an average Gregorian year of 365.2425 days. Adding a duration to a date follows the rule used by java.time and by many libraries: the years and months are added first, and if the day does not exist in the new month it moves back to the last day, so 31 January plus P1M is 28 February (29 in a leap year). Then the weeks, days and time are added. Dates are plain calendar dates with no time zone. Nothing is uploaded.
What does P and T mean in an ISO 8601 duration?▾
P stands for period and starts every duration. T separates the date part from the time part. Without T, an M means months, and after it an M means minutes, so P1M is one month and PT1M is one minute.
How do I write 90 minutes as an ISO 8601 duration?▾
PT90M, or PT1H30M. Both are valid, because the standard lets the largest part exceed its usual limit. The tool shows the shortest form of what you enter.
How many seconds are in a month or a year?▾
It depends on the month or year, so the standard gives no fixed answer. The tool uses an average Gregorian year of 365.2425 days for an approximate figure and marks it as approximate. Days, weeks, hours, minutes and seconds convert exactly.
What happens when I add one month to 31 January?▾
The result is 28 February, or 29 February in a leap year, because the day moves back to the last day of a shorter month. This is the same rule that java.time uses.
Is my data uploaded?▾
No. Everything is calculated in your browser and nothing is sent anywhere.