Calculate the difference in duration between 2 date objects, expressed in the specified time unit.
getTimeDiff(new Date(2020, 3, 2, 10, 30), new Date(2020, 3, 2, 8, 0), TimeUnit.HOURS)) // 2.5getTimeDiff(new Date(2020, 3, 10), new Date(2020, 3, 3), TimeUnit.DAYS)) // 7getTimeDiff(new Date(2020, 3, 10), new Date(2020, 1, 10), TimeUnit.MONTHS)) // 2
Time difference expressed in the specified time unit
JavaScript date object
JavaScript date object (this will be subtracted from date1)
Time unit to return
Generated using TypeDoc
Calculate the difference in duration between 2 date objects, expressed in the specified time unit.
Example
Returns
Time difference expressed in the specified time unit