Skip to content

human readable time seconds 人类可读时间 秒为单位

License

Notifications You must be signed in to change notification settings

chinanf-boy/what-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

what-time Build Status codecov

human readable time, inspire from https://github.com/bahamas10/human/blob/master/human.js

Install

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

Usage

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)

API

whatTime(timeNum, isSuffix)

timeNum

name: timeNum
Type: number|Date
Desc: time number like Date.now().

isSuffix

name: isSuffix
Type: boolean
Default: false
Desc: Is add the ago/from now

contact

use by

License

MIT © chinanf-boy

About

human readable time seconds 人类可读时间 秒为单位

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published