elapsed

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

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" 
var elapsedTime = new Elapsed(from, to);

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

  • 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)
  • __set()__: calculating the properties.
  • __refresh(to)__: refresh the to date. to is optional it defaults to now.