-
Notifications
You must be signed in to change notification settings - Fork 1
dateDiff
kherP edited this page Jan 2, 2020
·
3 revisions
This utility compares and returns the difference between two dates. To use it, pass the two dates and range to be calculated in.
const date1 = new Date("December 17, 2019");
const date2 = new Date("December 17, 1995");
const result = dateDiff(date1, date2, "year");
console.log(result); // 24
Param | Type | Description |
---|---|---|
firstDate | Date | First date |
secondDate | Date | Second date to be compared against |
range | moment.DurationInputArg2 | Difference return unit, example: months | seconds | h | m | y
|