Convert milliseconds to a human readable string: 1337000000 → 15d 11h 23m 20s.
1337000000
15d 11h 23m 20s
import formatMilliseconds from '@oliversalzburg/js-utils/format/milliseconds.js';formatMilliseconds(1337000000);//=> '15d 11h 23m 20s'formatMilliseconds(1337);//=> '1.3s'formatMilliseconds(133);//=> '133ms'// `compact` optionformatMilliseconds(1337, {compact: true});//=> '1s'// `verbose` optionformatMilliseconds(1335669000, {verbose: true});//=> '15 days 11 hours 1 minute 9 seconds'// `colonNotation` optionformatMilliseconds(95500, {colonNotation: true});//=> '1:35.5'// `formatSubMilliseconds` optionformatMilliseconds(100.400080, {formatSubMilliseconds: true})//=> '100ms 400µs 80ns'// Can be useful for time durationsformatMilliseconds(new Date(2014, 0, 1, 10, 40) - new Date(2014, 0, 1, 10, 5))//=> '35m' Copy
import formatMilliseconds from '@oliversalzburg/js-utils/format/milliseconds.js';formatMilliseconds(1337000000);//=> '15d 11h 23m 20s'formatMilliseconds(1337);//=> '1.3s'formatMilliseconds(133);//=> '133ms'// `compact` optionformatMilliseconds(1337, {compact: true});//=> '1s'// `verbose` optionformatMilliseconds(1335669000, {verbose: true});//=> '15 days 11 hours 1 minute 9 seconds'// `colonNotation` optionformatMilliseconds(95500, {colonNotation: true});//=> '1:35.5'// `formatSubMilliseconds` optionformatMilliseconds(100.400080, {formatSubMilliseconds: true})//=> '100ms 400µs 80ns'// Can be useful for time durationsformatMilliseconds(new Date(2014, 0, 1, 10, 40) - new Date(2014, 0, 1, 10, 5))//=> '35m'
Milliseconds to humanize.
Options for humanizing the milliseconds.
The humanized string.
Convert milliseconds to a human readable string:
1337000000
→15d 11h 23m 20s
.Example