human readable time, inspire from https://github.com/bahamas10/human/blob/master/human.js
npm install what-time
yarn add what-time
⚠️
const whatTime = require('what-time');
let s = Date.now() // the number is miniseconds
// something run
let e = Date.now()
console.log(whatTime((s-e) / 1000) // whatTime is seconds , pleace /1000
const whatTime = require('what-time');
whatTime(1810.999)
// "30m 10s 999ms "
whatTime(1810.999,true)
// "30m 10s 999ms ago"
whatTime(1527824212)
//"48Y 5M 1W 6d 3h 36m 52s "
whatTime(1527824212,true)
//"48Y 5M 1W 6d 3h 36m 52s ago"
whatTime(new Date(0))
// now() - Thu Jan 01 1970 08:00:00 GMT+0800 (CST)
name: | timeNum |
---|---|
Type: | number|Date |
Desc: | time number like Date.now(). |
name: | isSuffix |
---|---|
Type: | boolean |
Default: | false |
Desc: | Is add the ago /from now |
- reverse-what-time reverse human time to number
- node-modules-size get all node_modules size
MIT © chinanf-boy