get a difference between 2 dates in human readable format
npm install time-diff-for-humansget difference between 2 dates in a human readable format, in javascript
run
``sh`
npm i time-diff-for-humans
import
`sh`
const timeDiff = require("time-diff-for-humans");
or
import timeDiff from "time-diff-for-humans";
`sh`
timeDiff('2022-07-21 12:28:57'); // returns '7 hours ago'
`sh`
timeDiff("2022-07-21 19:28:57"); // '58 minutes ago'
`sh`
timeDiff("2022-03-21"); // '4 months ago'
`sh`
timeDiff("2021-03-21"); // '1 year ago'
you can also pass a locale as a second argument
(currently supported locales are only en and ka)
`sh``
timeDiff("2022-07-21 19:28:57", "ka"); //returns '1 საათის წინ'