Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Free tool · Developer tools

Duration format converter

Paste one duration and see it in every common form. The starting example, P1DT2H30M, is 26:30:00 as a clock, 1 day, 2 hours, 30 minutes in words and 95,400 seconds in total.

  • Free
  • No sign-up
  • Runs in your browser

By Maaz Zindani · Updated

An ISO 8601 string, a clock time, words or plain seconds.
Input format
ISO 8601 duration converted

P1DT2H30M26:30:00 as a clock, 1 day, 2 hours, 30 minutes

  • Read as: ISO 8601 duration
  • 1 day, 2 hours, 30 minutes
ISO 8601
P1DT2H30M
Clock
26:30:00
Words
1 day, 2 hours, 30 minutes
Short form
1d 2h 30m
Total seconds
95,400
Total milliseconds
95,400,000
Total minutes
1,590
Total hours
26.5
Total days
1.1042

How to use the Duration Format Converter (ISO 8601)

  1. Type or paste the duration under Duration to convert, or press one of the example buttons.
  2. Leave Input format on Detect, or pick the format yourself if a plain number should be read as milliseconds, minutes or hours.
  3. Read the large ISO 8601 answer and the clock and words lines under it.
  4. Press Copy ISO 8601 or Copy clock, or read the totals in seconds, minutes, hours and days.

How do I convert an ISO 8601 duration to hours, minutes and seconds?

An ISO 8601 duration is a text string that always begins with the letter P. The date part comes next, with a number before each letter: Y for years, M for months, W for weeks and D for days. If a time part follows, it starts with T and uses H for hours, M for minutes and S for seconds. The letter M appears in both parts, and the T tells them apart: P3M is three months, while PT3M is three minutes.

Take P1DT2H30M. It reads one day, two hours and thirty minutes. The converter adds the parts as exact milliseconds, 95,400,000 in all, and then writes the total again. As a clock it is 26:30:00, because the clock counts hours without wrapping at 24. In words it is 1 day, 2 hours, 30 minutes, which equals 26.5 hours or 1,590 minutes.

The last number may carry a decimal part. PT1.5H is an hour and a half, and PT0.25S is a quarter of a second, which the page shows as 0:00:00.250 on the clock. A decimal on any number before the last is rejected, and so are strings with a dangling T such as P1DT.

Six durations in the other formats
You typeISO 8601ClockShort form
PT45SPT45S0:00:4545s
PT90MPT1H30M1:30:001h 30m
PT1H30M5SPT1H30M5S1:30:051h 30m 5s
P1DT12HP1DT12H36:00:001d 12h
P2WP14D336:00:0014d
PT0.25SPT0.25S0:00:00.2500.25s

How do I turn seconds or a clock time into an ISO 8601 duration?

Choose what a plain number means and the page does the rest. 5405 seconds is 1 hour, 30 minutes and 5 seconds, so the ISO form is PT1H30M5S. A clock time with two parts is read as minutes and seconds, so 90:30 is PT1H30M30S. With three parts it is hours, minutes and seconds, and the minutes and seconds must stay below 60, so 1:75:00 gets an error that names the minutes.

Words work too. 2 hours and 15 minutes becomes PT2H15M. The page knows w, d, h, m, s and ms and their long forms, and it accepts lists written without spaces, such as 1h30m. The written ISO form always uses days and a time part, with no weeks, so the output follows the RFC 3339 grammar whenever no milliseconds remain.

Other inputs, written as ISO 8601 and as a clock
You typeISO 8601Clock
5405PT1H30M5S1:30:05
90:30PT1H30M30S1:30:30
2 hours and 15 minutesPT2H15M2:15:00
25:00:00.5P1DT1H0.5S25:00:00.500

How are years, months and weeks converted?

Years and months have no fixed length, so a duration such as P1Y2M3DT4H5M6S has no single length in seconds. The page picks a rule and states it in the result: a year counts as 365 days and a month as 30 days. Under that rule the example is 36,993,906 seconds, written back as P428DT4H5M6S. Use a date library when you need real calendar months, since a month from 31 January and a month from 1 February are different lengths.

A week is exactly seven days, so P2W becomes P14D. A leading minus sign marks a negative duration, and -PT5M comes out as -PT5M and -0:05:00. Values are kept to the millisecond, and anything beyond that is rounded half up.

The grammar in RFC 3339 Appendix A allows weeks only on their own and writes every number as plain digits. Reading weeks beside days, and a decimal on the last number, are extensions that other tools also accept, so the converter reads them. The text it writes uses only days, hours, minutes and seconds, with decimals on the seconds when milliseconds remain.

Use it with

  • Unix Timestamp Converter: epoch to date and back.
  • Time Duration Calculator: time duration calculator: enter a start and end date with times, and get the days, hours and minutes between them, across midnight and time zones.
  • Seconds Converter: seconds converter: type a number of seconds, minutes, hours, days or weeks and get every other unit plus a clock time, with the working shown.

Questions

What does PT1H30M mean?

One hour and thirty minutes. The T starts the time part, H counts hours and M counts minutes. It is 1:30:00 on a clock and 5,400 seconds.

How do I write 90 minutes as an ISO 8601 duration?

Either PT90M or the normalized form PT1H30M. The converter writes the normalized form and both mean the same length.

What is the difference between P3M and PT3M?

The letter before the M decides it. P3M is three months because it is in the date part, and PT3M is three minutes because it follows the T.

How many seconds are in P1D?

86,400. A day is counted as 24 hours, with no allowance for clock changes.

Why does a year count as 365 days here?

A year or a month has no fixed length, so the page uses 365 and 30 days and says so in the result. For exact calendar months use a date tool.

Can I convert a clock time such as 26:30:00?

Yes. The hours can pass 24. 26:30:00 gives P1DT2H30M.

The tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations are checked against the tool's own output.