Skip to content

alanclarke/how-long

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

Break down the difference between two js dates into customisable units

Resources

Stars

Watchers

Forks

Packages

No packages published