Function: humanizeDuration()
ts
function humanizeDuration(ms, options?): string;Convert a duration in milliseconds to a human-readable string. 将毫秒时长转换为可读字符串,如 "1 hour 30 minutes" / "1小时30分钟"。
Parameters
| Parameter | Type |
|---|---|
ms | number |
options | HumanizeDurationOptions |
Returns
string
Example
ts
humanizeDuration(5400000) // => '1小时30分钟'
humanizeDuration(5400000, { locale: 'en' }) // => '1 hour 30 minutes'
humanizeDuration(90061000, { largest: 3 }) // => '1天1小时1分钟'Since
1.0.0