JS Interval to Human Readable Text Converter
Convert JavaScript millisecond intervals to human readable text. Supports seconds, minutes, hours, days, weeks, months, years with plural forms.
1000 * 60 * 60 * 24
About
JavaScript timing functions like setTimeout and setInterval operate in milliseconds. A value like 86400000 is meaningless at a glance. Misreading a single zero means the difference between a 1‐day cache expiry and a 10‐day one. This tool decomposes any millisecond integer into its human‐readable components: years, months, weeks, days, hours, minutes, seconds, and remaining milliseconds. It uses integer division cascading from the largest applicable unit downward.
The converter supports a "max unit" cap. Setting it to days forces the output to express 604800000 ms as 7 days instead of 1 week. This matches real‐world API documentation patterns where durations are stated in a specific granularity. Note: months are approximated at 30.44 days (average Gregorian month) and years at 365.25 days. For calendar‐precise durations, use a date library.
Formulas
The decomposition algorithm uses cascading integer division. Given an input T in milliseconds and an ordered list of unit divisors, the value for each unit is extracted sequentially:
Where qi is the quantity for unit i, di is that unit's divisor in milliseconds, and Trem is the running remainder (initialized to input T). The unit divisors used are:
Pluralization rule: if qi = 1, use singular form. Otherwise use plural. When a "max unit" is selected, all units above it are excluded from the divisor list, causing their time to accumulate in the highest allowed unit.
Reference Data
| Unit | Abbreviation | Milliseconds | Example Input | Human Output |
|---|---|---|---|---|
| Millisecond | ms | 1 | 500 | 500 milliseconds |
| Second | s | 1,000 | 1000 | 1 second |
| Minute | m | 60,000 | 65000 | 1 minute, 5 seconds |
| Hour | h | 3,600,000 | 3661000 | 1 hour, 1 minute, 1 second |
| Day | d | 86,400,000 | 90061000 | 1 day, 1 hour, 1 minute, 1 second |
| Week | w | 604,800,000 | 604800000 | 1 week |
| Month (avg) | mo | 2,630,016,000 | 2630016000 | 1 month |
| Year (avg) | y | 31,557,600,000 | 31557600000 | 1 year |
| Common: 1 min timeout | - | 60,000 | 60000 | 1 minute |
| Common: 5 min debounce | - | 300,000 | 300000 | 5 minutes |
| Common: 15 min session | - | 900,000 | 900000 | 15 minutes |
| Common: 30 min poll | - | 1,800,000 | 1800000 | 30 minutes |
| Common: 1 hour cache | - | 3,600,000 | 3600000 | 1 hour |
| Common: 24 hour expiry | - | 86,400,000 | 86400000 | 1 day |
| Common: 7 day token | - | 604,800,000 | 604800000 | 1 week |
| Common: 30 day cookie | - | 2,592,000,000 | 2592000000 | 30 days |
| Common: 90 day refresh | - | 7,776,000,000 | 7776000000 | 2 months, 28 days, 3 hours, 27 minutes, 28 seconds |
| Common: 365 day cert | - | 31,536,000,000 | 31536000000 | 11 months, 30 days, 2 hours, 24 seconds |