Milliseconds to Human Readable Time Converter
Convert milliseconds to human readable time strings. Supports compact, verbose, colon notation, sub-milliseconds, and 15+ formatting options.
About
Raw millisecond values are ubiquitous in software logs, performance profiling, API response headers, and process.hrtime output. Misreading 1337000000ms as "about 13 million seconds" instead of the correct 15d 11h 23m 20s leads to incorrect timeout configurations, flawed SLA reports, and misdiagnosed latency bottlenecks. This converter decomposes any millisecond value - including sub-millisecond precision down to nanoseconds - into human-parseable duration strings using cascading integer division through time units from years (365.25 days) down to nanoseconds. It replicates the full API surface of the pretty-ms specification: compact mode, verbose labels, colon notation for digital-clock style, configurable decimal digits, unit count limits, and independent control over year, day, and second visibility. The tool assumes fixed-length days (86400s) and years (365.25d); it does not account for leap seconds or calendar irregularities because it formats durations, not calendar dates.
Formulas
The conversion decomposes a millisecond value t through cascading integer division across fixed time-unit boundaries:
years = t31557600000
days = t mod 3155760000086400000
hours = t mod 864000003600000
minutes = t mod 360000060000
seconds = t mod 600001000
ms = t mod 1000
Where the constants derive from: 1y = 365.25 Γ 24 Γ 3600 Γ 1000 = 31557600000ms. For sub-millisecond decomposition with formatSubMilliseconds enabled: ΞΌs = floor(fractional_ms Γ 1000) and ns = floor(fractional_ΞΌs Γ 1000). Each unit extraction uses floor division; the remainder cascades to the next smaller unit. The colonNotation mode formats as H:MM:SS with zero-padded minutes and seconds, always showing at least M:SS.
Reference Data
| Millisecond Value | Default Output | Compact | Verbose | Colon Notation |
|---|---|---|---|---|
| 500 | 500ms | 500ms | 500 milliseconds | 0:00.5 |
| 1337 | 1.3s | 1s | 1.3 seconds | 0:01.3 |
| 5000 | 5s | 5s | 5 seconds | 0:05 |
| 60000 | 1m | 1m | 1 minute | 1:00 |
| 95500 | 1m 35.5s | 1m | 1 minute 35.5 seconds | 1:35.5 |
| 3600000 | 1h | 1h | 1 hour | 1:00:00 |
| 86400000 | 1d | 1d | 1 day | 24:00:00 |
| 1335669000 | 15d 11h 1m 9s | 15d | 15 days 11 hours 1 minute 9 seconds | 371:01:09 |
| 31557600000 | 1y | 1y | 1 year | 8766:00:00 |
| 100400080 | 1d 3h 53m 20s | 1d | 1 day 3 hours 53 minutes 20 seconds | 27:53:20 |
| 0.0005 | 0ms | 0ms | 0 milliseconds | 0:00 |
| 100.40008 (sub-ms) | 100ms | 100ms | 100 milliseconds | 0:00.1 |