{"id":15645910,"url":"https://github.com/jonschlinkert/pretty-time","last_synced_at":"2025-07-04T20:37:42.574Z","repository":{"id":57330180,"uuid":"44097771","full_name":"jonschlinkert/pretty-time","owner":"jonschlinkert","description":"Easily format the time from node.js `process.hrtime`. Works with timescales ranging from weeks to nanoseconds.","archived":false,"fork":false,"pushed_at":"2019-06-11T16:54:01.000Z","size":19,"stargazers_count":52,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-19T22:09:26.023Z","etag":null,"topics":["diff","format","hour","hrtime","increment","javascript","jonschlinkert","nanoseconds","node","nodejs","pretty","time","timescale"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-12T09:33:23.000Z","updated_at":"2024-04-20T00:17:17.000Z","dependencies_parsed_at":"2022-09-21T02:20:48.596Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/pretty-time","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jonschlinkert/pretty-time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpretty-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpretty-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpretty-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpretty-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/pretty-time/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpretty-time/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261624268,"owners_count":23186095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diff","format","hour","hrtime","increment","javascript","jonschlinkert","nanoseconds","node","nodejs","pretty","time","timescale"],"created_at":"2024-10-03T12:10:33.400Z","updated_at":"2025-07-04T20:37:42.543Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pretty-time [![NPM version](https://img.shields.io/npm/v/pretty-time.svg?style=flat)](https://www.npmjs.com/package/pretty-time) [![NPM monthly downloads](https://img.shields.io/npm/dm/pretty-time.svg?style=flat)](https://npmjs.org/package/pretty-time) [![NPM total downloads](https://img.shields.io/npm/dt/pretty-time.svg?style=flat)](https://npmjs.org/package/pretty-time) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/pretty-time.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/pretty-time)\n\n\u003e Easily format the time from node.js `process.hrtime`. Works with timescales ranging from weeks to nanoseconds.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save pretty-time\n```\n\n## Usage\n\n```js\nvar pretty = require('pretty-time');\n\nvar start = process.hrtime();\nvar time = process.hrtime(start);\nconsole.log(pretty(time));\n//=\u003e 3μs\n```\n\n## API\n\nBy 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_).\n\n**Examples:**\n\n```js\npretty([1200708, 795428088]);\n//=\u003e '2w'\n\npretty([800708, 795428088]);\n//=\u003e '1w'\n\npretty([400708, 795428088]);\n//=\u003e '5d'\n\npretty([70708, 795428088]);\n//=\u003e '20h'\n\npretty([12708, 795428088]);\n//=\u003e '4h'\n\npretty([3708, 795428088]);\n//=\u003e '1h'\n\npretty([208, 795428088]);\n//=\u003e '3m'\n\npretty([20, 795428088]);\n//=\u003e '21s'\n\npretty([0, 795428088]);\n//=\u003e '795ms'\n\npretty([0, 000428088]);\n//=\u003e '428μs'\n\npretty([0, 000000088]);\n//=\u003e '88ns'\n\npretty([0, 000000018]);\n//=\u003e '18ns'\n```\n\n### Minimum time increment\n\n_(All of the following examples use `[6740, 795428088]` as the hrtime array.)_\n\nThis value is passed as the second argument and determines how granular to make the time.\n\n**Examples**\n\n```js\npretty(time, 'h');\n//=\u003e '2h'\n\npretty(time, 'm');\n//=\u003e '1h 52m'\n\npretty(time, 's');\n//=\u003e '1h 52m 21s'\n```\n\n**Valid time increments**\n\nAny of the following may be used:\n\n* `ns` | `nano` | `nanosecond` | `nanoseconds`\n* `μs` | `micro` | `microsecond` | `microseconds`\n* `ms` | `milli` | `millisecond` | `milliseconds`\n* `s` | `sec` | `second` | `seconds`\n* `m` | `min` | `minute` | `minutes`\n* `h` | `hr` | `hour` | `hours`\n* `d` | `day` | `days`\n* `w` | `wk` | `week` | `weeks`\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning 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:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [o-clock](https://www.npmjs.com/package/o-clock): Simple javascript utility for displaying the time in 12-hour clock format. | [homepage](https://github.com/jonschlinkert/o-clock \"Simple javascript utility for displaying the time in 12-hour clock format.\")\n* [seconds](https://www.npmjs.com/package/seconds): Get the number of seconds for a minute, hour, day and week. | [homepage](https://github.com/jonschlinkert/seconds \"Get the number of seconds for a minute, hour, day and week.\")\n* [time-stamp](https://www.npmjs.com/package/time-stamp): Get a formatted timestamp. | [homepage](https://github.com/jonschlinkert/time-stamp \"Get a formatted timestamp.\")\n* [timescale](https://www.npmjs.com/package/timescale): Convert from one time scale to another. Nanosecond is the most atomic unit, week is… [more](https://github.com/jonschlinkert/timescale) | [homepage](https://github.com/jonschlinkert/timescale \"Convert from one time scale to another. Nanosecond is the most atomic unit, week is the largest unit.\")\n* [week](https://www.npmjs.com/package/week): Get the current week number. | [homepage](https://github.com/datetime/week \"Get the current week number.\")\n* [weekday](https://www.npmjs.com/package/weekday): Get the name and number of the current weekday. Or get the name of the… [more](https://github.com/datetime/weekday) | [homepage](https://github.com/datetime/weekday \"Get the name and number of the current weekday. Or get the name of the weekday for a given number.\")\n* [year](https://www.npmjs.com/package/year): Simple utility to get the current year with 2 or 4 digits. | [homepage](https://github.com/jonschlinkert/year \"Simple utility to get the current year with 2 or 4 digits.\")\n\n### Contributors\n\n| **Commits** | **Contributor** | \n| --- | --- |\n| 14 | [jonschlinkert](https://github.com/jonschlinkert) |\n| 5 | [doowb](https://github.com/doowb) |\n\n### Author\n\n**Jon Schlinkert**\n\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 12, 2018._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fpretty-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fpretty-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fpretty-time/lists"}