安装
pnpm i pretty-ms
接口
prettyMilliseconds(milliseconds, options?)
示例
import prettyMilliseconds from 'pretty-ms' // 基本用法:直接传入毫秒 let time = prettyMilliseconds(1337000000) console.log(time) // 15d 11h 23m 20s // 实例:统计起始时间差(毫秒级) let start = new Date(2014, 0, 1, 10, 40).getTime() let end = new Date(2014, 0, 1, 10, 5).getTime() let time = prettyMilliseconds(start - end) console.log(time) // 35m