https://github.com/binarykitchen/pretty-seconds
a very simple function to stringify any huge number of seconds. give it million seconds and it tells you how many days, hours, minutes and seconds in a pretty string.
https://github.com/binarykitchen/pretty-seconds
Last synced: 8 months ago
JSON representation
a very simple function to stringify any huge number of seconds. give it million seconds and it tells you how many days, hours, minutes and seconds in a pretty string.
- Host: GitHub
- URL: https://github.com/binarykitchen/pretty-seconds
- Owner: binarykitchen
- License: mit
- Created: 2013-04-01T02:34:53.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T19:57:58.000Z (over 3 years ago)
- Last Synced: 2025-08-31T20:22:39.970Z (10 months ago)
- Language: JavaScript
- Homepage: https://npmjs.org/package/pretty-seconds
- Size: 16.6 KB
- Stars: 11
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pretty-seconds
[](https://travis-ci.org/binarykitchen/pretty-seconds)
a very simple function to stringify any huge number of seconds. give it million seconds and it tells you how many days, hours, minutes and seconds in a pretty string.
## installation
to install pretty-seconds, use [npm](http://github.com/isaacs/npm):
$ npm install pretty-seconds
then in your node.js app, get reference to the function like that:
```javascript
var prettySeconds = require('pretty-seconds');
```
## quick examples
### make a pretty string out of 80 seconds
```javascript
// outputs "1 minute and 20 seconds"
echo prettySeconds(80);
```
### make a pretty string out of 86462 seconds
```javascript
// outputs "1 day, 1 minute and 2 seconds"
echo prettySeconds(86462);
```
you see, it's really pretty and respects grammar for singular and plural.
## api
### prettySeconds(seconds)
all this function does is some maths and string concenations to have a pretty string instead of a long number of seconds.
__arguments__
* seconds - any positive or negative number (integer or float) you fancy
## license
MIT