Duration humanizer — milliseconds to 1d 2h 3m 4s, ISO 8601 and clock time

Enter a duration in milliseconds, seconds, minutes, hours or days and get it as compact text (1d 2h 3m 4s), a full sentence, an ISO 8601 duration and hh:mm:ss clock time, plus the total in every unit.

Live demo · real result from this tool
Compact1d 2h 3m 4s
Long
1 day, 2 hours, 3 minutes and 4 seconds
ISO 8601
P1DT2H3M4S
Clock
26:03:04

Total in each unit

UnitTotal
Milliseconds93,784,000
Seconds93,784
Minutes1,563.0667
Hours26.0511
Days1.0855
Weeks0.1551

Breakdown

DaysHoursMinutesSecondsMilliseconds
12340

Processed on your device — nothing is uploaded.

How to use the duration humanizer

  1. Type the number into Duration. Decimals and negative numbers are allowed.
  2. Choose the Unit: Milliseconds, Seconds, Minutes, Hours or Days.
  3. Read the four formats at the top: Compact, Long, ISO 8601 and Clock.
  4. Use the Total in each unit table for the same span as one number in each unit, and the Breakdown row for days, hours, minutes, seconds and milliseconds.

What it does and when to use it

Logs, metrics and APIs report time as raw numbers, such as "elapsed_ms": 93784000 or an uptime in seconds. This tool turns them into something a person can read, and into formats that code and config expect. For example, ISO 8601 durations appear in YouTube’s API, XML Schema and many scheduling systems, and hh:mm:ss suits video lengths and timers.

Common uses are reading a job’s runtime from a log, setting a timeout or cache TTL (how many seconds is 2.5 hours?), and writing a PT… value into a config file.

To measure the time between two dates, use the timestamp diff calculator. To turn a Unix timestamp into a date, use the Unix timestamp converter. For sizes in bytes, the bytes humanizer does the same job.

How it works

The value is converted to milliseconds (seconds × 1,000, minutes × 60,000, hours × 3,600,000, days × 86,400,000). Its absolute value is then split from the largest unit down: whole days, then hours, minutes, seconds and the remaining milliseconds. Each format is built from those parts:

  • Compact and Long list only the non-zero parts.
  • ISO 8601 writes P, the days, then T and the hours, minutes and seconds. Milliseconds become decimal seconds, and zero is PT0S.
  • Clock shows total hours (days × 24 + hours), minutes and seconds, with .mmm added when there are milliseconds.

A minus sign is added to every format for negative input. It all runs in your browser.

Worked examples

93784000 milliseconds:

Compact: 1d 2h 3m 4s
Long: 1 day, 2 hours, 3 minutes and 4 seconds
ISO 8601: P1DT2H3M4S
Clock: 26:03:04

1500 milliseconds shows how fractions are handled:

Compact: 1s 500ms
ISO 8601: PT1.5S
Clock: 00:00:01.500

2.5 hours gives 2h 30m, PT2H30M and a total of 9,000 seconds, which is the number to put in a max-age or a TTL.

Limits and tips

  • Days are 24 hours. Across a daylight-saving change a calendar day can be 23 or 25 hours, which this tool does not model.
  • Table totals are rounded to 3 or 4 decimal places, so very short spans show 0 days or weeks.
  • Very large values keep working, but the day count grows without limit; there is no year unit.

Frequently asked questions

Why does it stop at days instead of showing months or years?
Months and years have no fixed length (28–31 days, 365 or 366), so a duration in milliseconds cannot be split into them exactly. The largest unit is the day, and 400 days stays 400 days. For a calendar difference between two dates, use the timestamp diff tool.
Why is Clock 26:03:04 and not 1 day 02:03:04?
Clock adds days into the hours, which is how timers, video lengths and many log formats show long durations. Read the day count from the Compact or Breakdown output.
Can I paste a value like 1h30m to convert it back?
No. The input is a single number plus a unit. Convert 1h30m by entering 90 with Minutes, or 1.5 with Hours.
How are negative durations shown?
With a leading minus, for example -1h and -PT1H. Some ISO 8601 parsers do not accept a sign, since the base standard has no negative durations, so check yours before relying on it.
What about microseconds or nanoseconds?
The smallest unit is the millisecond, and fractions of a millisecond are rounded. For nanosecond timings, divide by 1,000,000 and enter milliseconds.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close