bitlvl
EN

Duration converter

Type a duration in any form. You get it in every unit, as a clock time, as a readable phrase and as an ISO 8601 string.

ISO 8601 durations

The ISO format writes a duration as P followed by date parts and, after a T, time parts: P1Y2M3DT4H5M6S is one year, two months, three days, four hours, five minutes and six seconds. Weeks have their own form, P2W. Parts may be omitted (PT30M, P1D) and the last part may have decimals (PT0.5S). The T is what distinguishes months from minutes: P1M is a month, PT1M a minute.

You meet it in iCalendar (DURATION:PT1H), YouTube and schema.org metadata, Kubernetes manifests, Java's Duration.parse, .NET's XmlConvert and many REST APIs. Years and months have no fixed length, so a duration containing them cannot be converted to seconds exactly; this tool uses the average year (365.25 days) and month (30.4375 days) and says so.

Other notations

FormExampleWhere
Seconds5400Unix tools, TTLs, timeouts in most config files
Milliseconds5400000JavaScript, Java, logging
Clock1:30:00Media players, spreadsheets, ffmpeg
Go-style1h30m, 500ms, 1.5hGo, Prometheus, Docker, Caddy, many CLIs
systemd1h 30min, 90min, 2 dayssystemd timers and unit options
ISO 8601PT1H30MAPIs, iCalendar, Java, .NET

Traps

  • 1:30 means 1 minute 30 seconds in media players and 1 hour 30 minutes in spreadsheets. The tool reads h:mm:ss when there are two colons and h:mm with one; add seconds to be unambiguous.
  • Go's time.ParseDuration has no day unit; 24h is the largest. systemd accepts d, w, month and y.
  • A duration in months is not a number of seconds. Store it as the ISO string if the calendar meaning matters (billing periods), or as seconds if the elapsed time matters (timeouts).

Questions

How many seconds are in an hour, a day, a week?

3,600 in an hour, 86,400 in a day, 604,800 in a week. A 30-day month is 2,592,000 and a 365-day year 31,536,000 seconds.

What does PT1H30M mean?

An ISO 8601 duration of 1 hour 30 minutes. P starts the duration, T separates the time part, H and M are hours and minutes.

How do I convert milliseconds to minutes?

Divide by 60,000. 90,000 ms is 1.5 minutes. Type the value with ms (90000ms) and the tool shows every unit.

How long is a month in seconds?

It depends on the month: 28–31 days, or 2,419,200–2,678,400 seconds. For averages, 30.4375 days (2,629,800 s) is the mean Gregorian month, which is what this converter uses for P1M.