time-diff-for-humans

1.0.3 • Public • Published

time-diff-for-humans

get difference between 2 dates in a human readable format, in javascript

Getting Started

run

npm i time-diff-for-humans

import
const timeDiff = require("time-diff-for-humans");
or
import timeDiff from "time-diff-for-humans";

pass into the function a string which is in any valid date format


examples
timeDiff('2022-07-21 12:28:57'); // returns '7 hours ago'
timeDiff("2022-07-21 19:28:57"); // '58 minutes ago'
timeDiff("2022-03-21"); // '4 months ago'
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`)
timeDiff("2022-07-21 19:28:57", "ka"); //returns '1 საათის წინ'

Package Sidebar

Install

npm i time-diff-for-humans

Weekly Downloads

4

Version

1.0.3

License

ISC

Unpacked Size

5.28 kB

Total Files

4

Last publish

Collaborators

  • davidbuchukuri