🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

prettytime

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettytime

A node micro library for converting millis into a human friendly format.

1.0.0
latest
Source
npm
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

Prettytime Build Status npm

Prettytime is a micro library for converting millis (e.g. prettytime(2342)) into a human friendly format (e.g. 2.3 seconds).

Install

$ npm install prettytime

Usage

var prettytime = require('prettytime');

var now = Date.now();

...

prettytime(now - Date.now());
// => 2.3 seconds

Examples

prettytime(100);     // => 100 ms
prettytime(1000);    // => 1 second
prettytime(5000);    // => 5 seconds
prettytime(60000);   // => 1 minute
prettytime(3600000); // => 1 hour

Options

options.decimals

Allows you to set the decimal limit of the returned values, always rounded to the nearest significant decimal

Examples

prettytime(1236, { decimals: 1 }); // => 1.2 seconds
prettytime(1236, { decimals: 2 }); // => 1.24 seconds

options.short

Converts the time type to a short string.

FullShort
yeary
monthmo
dayd
hourh
minutem
seconds
msms

Examples

prettytime(100, { short: true});     // => 100 ms
prettytime(1000, { short: true});    // => 1 s
prettytime(60000, { short: true});   // => 1 m
prettytime(3600000, { short: true}); // => 1 h

License

MIT © Jason Wilson

Keywords

time

FAQs

Package last updated on 15 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts