elapsed

A module for getting the elapsed time between two dates in various representation.

npm install elapsed
20 downloads in the last week
40 downloads in the last month

Elapsed

npm install elapsed

A module for getting the elapsed time between two dates in various representation.

var Elapsed = require('elapsed');

var elapsedTime = new Elapsed(new Date(2013, 05, 2), new Date(2013, 05, 25));

console.log(elapsedTime.minutes.num); // 33120
console.log(elapsedTime.hours.text);  // "552 hours"
console.log(elapsedTime.optimal);     // "3 weeks"

create

var elapsedTime = new Elapsed(from, to);

The from (required) and to (optional, default: now) must be Date objects.

properties

  • milliSeconds: (Object), num property is the time in Number, text is the time in String.
  • seconds: (Object), num property is the time in Number, text is the time in String.
  • minutes: (Object), num property is the time in Number, text is the time in String.
  • hours: (Object), num property is the time in Number, text is the time in String.
  • days: (Object), num property is the time in Number, text is the time in String.
  • weeks: (Object), num property is the time in Number, text is the time in String.
  • months: (Object), num property is the time in Number, text is the time in String.
  • years: (Object), num property is the time in Number, text is the time in String.
  • optimal: (String), the best from the ones above.
  • from: (Date)
  • to: (Date)

methods

  • set(): calculating the properties.
  • refresh(to): refresh the to date. to is optional it defaults to now.
npm loves you