Time Between Dates
Simple script to measure time between two dates. Returns result in miliseconds, seconds, minutes, hours, days, weeks or years.
Installation
Install via npm
$ npm install time-between-dates
... or yarn
$ yarn add time-between-dates
then require
var timeBetweenDates = ;
or import
Usage
timeBetweenDates(date, date2, unit, decimal);
Provide two dates, time unit and decimal places are optional
Examples
// some datesvar x = 'November 10, 2017 11:25:24';var y = 'November 15, 2017 05:12:10'; // time in miliseconds (default); // returns 409606000 // time in seconds (rounded to fixed); // returns 409606 // time in minutes (one decimal place); // returns 6826.8 // ... and so on; // returns 113.779; // returns 4.74; // returns 0.677; // returns 0.013 // "time since"var now = Date;;
Author
Kuba Paczyński
License
Copyright © 2017, Kuba Paczyński. Released under the MIT License.