Duration Converter
runs in your browserConvert between 2h30m, ISO 8601 PT2H30M, seconds, milliseconds and plain English. Paste a list and every line converts on its own, with a total.
One duration per line. 2h30m, PT2H30M, 1 hour and 30 minutes and a bare number all read the same, and every line converts on its own.
Durations
ISO 8601
about this tool
Four notations for the same thing, and none of them reads the others. Go and
Prometheus write 2h30m. ISO 8601 writes PT2H30M. A config file writes
9000 and leaves you to work out the unit. A person writes "two and a half
hours". This converts between all of them, a list at a time.
The M problem
In ISO 8601, M means months before the T and minutes after it.
P1M is one month. PT1M is one minute. They differ by a single character
that looks like punctuation, and getting it wrong turns a one-minute timeout
into a one-month one. It is the reason the T is not optional when you mean
minutes, and the reason this tool reports the two separately rather than
folding them together.
Months and years have no length in seconds
A month is 28 to 31 days. A year is 365 or 366. Neither is a fixed number of seconds without knowing which month and which year.
ISO 8601 can write them, so P1M stays P1M in that column — nothing is lost
and nothing is guessed. The four notations that measure in seconds cannot hold
a month at all, so those cells say so rather than printing a number. A row
reading P1M → 0s would be a statement that one month is nothing.
Most converters pick 30 and 365 and say nothing about it. A converter that guesses is worse than one that says it cannot, because you cannot tell from the output that it guessed.
Bare numbers
90 is not a duration. It is a number that somebody, somewhere, decided meant
seconds — or milliseconds, or minutes. There is a control to say which, because
the file you copied it from knows and the number does not.
What it reads
Amounts and units in any order, run together or spaced out, with or without the words:
2h30m · 1d 4h 20m · 90 minutes · 1 hour and 30 minutes · 1.5h ·
500ms · -2h
Parts may repeat and need not descend — 30m 2h is two and a half hours,
because the tool reads what you wrote rather than enforcing a shape. A line it
cannot read is named beside the others instead of failing the whole list.
Nothing is sent
Everything runs in your browser. The durations in a paste are usually from a config file or a log, and neither needs to go anywhere.
For the timestamps these durations get added to, the Unix timestamp converter reads those, and date difference works out the gap between two dates.
questions
- What does PT2H30M mean?
- It is ISO 8601 for two hours thirty minutes. P starts the duration, T separates the date part from the time part, and each number carries its unit — so P1DT2H is one day two hours.
- Why does P1M mean a month but PT1M mean a minute?
- M means months before the T and minutes after it. That is the single thing people get wrong about this format, and it is why the T is not optional when you mean minutes.
- Can it convert a duration in months or years?
- Into ISO 8601, yes — P1M stays P1M, since that format can write a month. Into seconds, milliseconds or 2h30m, no: a month is 28 to 31 days and a year is 365 or 366, so there is no fixed number of seconds in either. Those columns say so instead of printing a number, rather than quietly using 30 days the way most converters do.
- What does a bare number like 90 mean?
- Whatever you tell it. A number on its own carries no unit, so there is a control to say whether the file you copied it from meant milliseconds, seconds, minutes, hours, days or weeks.
- Does it handle Go and Prometheus durations?
- Yes. 2h30m, 1500ms and 72h are all read the way Go and Prometheus write them, including several parts run together with no spaces.