how-long

1.0.6 • Public • Published

How long

Break down the difference between two js dates into customisable units, using this simple, fast, lightweight module.

Installation

npm install --save how-long
howLong(Date.now(), Date.now() + 61001, 'seconds')
{
  "seconds": 61
}
howLong(Date.now(), Date.now() + 61001, ['minutes', 'seconds'])
{
  "minutes": 1,
  "seconds": 1
}

If you do not specify time units, how-long will break down the difference in terms of all the time units it knows about:

howLong(Date.now(), Date.now() + 61001)
{
  "years": 0,
  "months": 0,
  "weeks": 0,
  "days": 0,
  "hours": 0,
  "minutes": 1,
  "seconds": 1,
  "milliseconds": 1
}

Readme

Keywords

none

Package Sidebar

Install

npm i how-long

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

7.43 kB

Total Files

4

Last publish

Collaborators

  • alz