timelabel

convert time lengths into a nice formatted string

timelabel

Convert time lengths (intervals) into a nice formatted string.

$ npm install timelabel

Test:

$ npm test

timelabel(number, [detail])

The function takes a number as its only required argument, assuming the number is a millisecond length and converts longer lengths it to a nicer format. If the detail argument is set to true then it will return more detail. See examples below.

Examples:

var timelabel = require('timelabel');
 
// milliseconds 
timelabel(150); // '150 milliseconds' 
 
// seconds 
timelabel(2400); // '2 seconds' 
 
// minutes 
timelabel(200000); // '3 minutes' 
timelabel(200000, true); // '3m 20s' 
 
// hours 
timelabel(38000000); // '11 hours' 
timelabel(38000000, true); // '10h 33m' 
 
// days 
timelabel(3810000000); // '44 days' 
timelabel(3810000000, true); // '44d 2h' 

MIT