Prettytime
Prettytime is a micro library for converting millis (e.g. prettytime(2342)
) into a human friendly format (e.g. 2.3 seconds
).
Install
$ npm install prettytime
Usage
var prettytime = ; var now = Date; ... ;// => 2.3 seconds
Examples
; // => 100 ms; // => 1 second; // => 5 seconds; // => 1 minute; // => 1 hour
Options
options.decimals
Allows you to set the decimal limit of the returned values, always rounded to the nearest significant decimal
Examples
; // => 1.2 seconds; // => 1.24 seconds
options.short
Converts the time type to a short string.
Full | Short |
---|---|
year | y |
month | mo |
day | d |
hour | h |
minute | m |
second | s |
ms | ms |
Examples
; // => 100 ms; // => 1 s; // => 1 m; // => 1 h
License
MIT © Jason Wilson