https://github.com/chinanf-boy/what-time
human readable time seconds 人类可读时间 秒为单位
https://github.com/chinanf-boy/what-time
readable time
Last synced: about 1 year ago
JSON representation
human readable time seconds 人类可读时间 秒为单位
- Host: GitHub
- URL: https://github.com/chinanf-boy/what-time
- Owner: chinanf-boy
- License: mit
- Created: 2018-06-01T03:50:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-05T00:54:09.000Z (almost 8 years ago)
- Last Synced: 2025-03-08T14:03:57.129Z (about 1 year ago)
- Topics: readable, time
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# what-time [](https://travis-ci.org/chinanf-boy/what-time) [](https://codecov.io/gh/chinanf-boy/what-time?branch=master)
> human readable time, inspire from https://github.com/bahamas10/human/blob/master/human.js
## Install
```
npm install what-time
```
```
yarn add what-time
```
> ⚠️
``` js
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
```js
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
- [reverse-what-time](https://github.com/chinanf-boy/reverse-what-time) reverse human time to number
## use by
- [node-modules-size](https://github.com/chinanf-boy/node-modules-size) get all node_modules size
## License
MIT © [chinanf-boy](http://llever.com)