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
| Form | Example | Where |
|---|---|---|
| Seconds | 5400 | Unix tools, TTLs, timeouts in most config files |
| Milliseconds | 5400000 | JavaScript, Java, logging |
| Clock | 1:30:00 | Media players, spreadsheets, ffmpeg |
| Go-style | 1h30m, 500ms, 1.5h | Go, Prometheus, Docker, Caddy, many CLIs |
| systemd | 1h 30min, 90min, 2 days | systemd timers and unit options |
| ISO 8601 | PT1H30M | APIs, iCalendar, Java, .NET |
Traps
1:30means 1 minute 30 seconds in media players and 1 hour 30 minutes in spreadsheets. The tool readsh:mm:sswhen there are two colons andh:mmwith one; add seconds to be unambiguous.- Go's
time.ParseDurationhas no day unit;24his the largest. systemd acceptsd,w,monthandy. - 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.