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.
npm install 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.
to install pretty-seconds, use npm:
$ npm install pretty-seconds
then in your node.js app, get reference to the function like that:
``javascript`
var prettySeconds = require('pretty-seconds');
`javascript
// outputs "1 minute and 20 seconds"
echo prettySeconds(80);
`
`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.
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
MIT