Easily format the time from node.js
process.hrtime. Works with timescales ranging from weeks to nanoseconds.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your ❤️ and support.
Install with npm:
$ npm install --save pretty-time
var pretty = ;var start = process;var time = process;console;//=> 3μs
By default, when no time increment is given as the second argument, the closest timescale is used (e.g. most granular without being less than zero).
;//=> '2w';//=> '1w';//=> '5d';//=> '20h';//=> '4h';//=> '1h';//=> '3m';//=> '21s';//=> '795ms';//=> '428μs';//=> '88ns';//=> '18ns'
Minimum time increment
(All of the following examples use
[6740, 795428088] as the hrtime array.)
This value is passed as the second argument and determines how granular to make the time.
;//=> '2h';//=> '1h 52m';//=> '1h 52m 21s'
Valid time increments
Any of the following may be used:
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
You might also be interested in these projects:
- seconds: Get the number of seconds for a minute, hour, day and week. | homepage
- time-stamp: Get a formatted timestamp. | homepage
- timescale: Convert from one time scale to another. Nanosecond is the most atomic unit, week is… more | homepage
- week: Get the current week number. | homepage
- weekday: Get the name and number of the current weekday. Or get the name of the… more | homepage
- year: Simple utility to get the current year with 2 or 4 digits. | homepage
This file was generated by verb-generate-readme, v0.6.0, on July 12, 2018.