how-long
v1.0.6
Published
break down the difference between two js dates into customisable units
Downloads
11
Readme
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
}