
time-diff.js is a modern JS library for calculating the time difference and getting human-readable timestamps from any two dates.
How to use it:
Installation.
# Yarn $ yarn add js-time-diff # NPM $ npm install js-time-diff --save
Import the TimeDiff module.
// ES 6
import TimeDiff from 'js-time-diff';
// CommonJS:
const TimeDiff = require('js-time-diff');Calculate the difference between 2 dates you specify.
// output: 5 days ago
TimeDiff('12-20-18', '12-25-18');If the second parameter is not provided, it will automatically uses the current local time.
// output: x days ago
TimeDiff('12-20-18');






