@spa-tools/utilities
daysDiff()
The daysDiff()
function calculates the number of days between two date values
where values can be date object, timestamp integer, or date string.
Usage
import { daysDiff } from '@spa-tools/utilities';
const date1 = new Date('2021-01-01');
const date2 = '2021-01-10';
const diff = daysDiff(date1, date2);
console.log(diff);
// --> 9
Arguments
Name | Type | Description |
---|---|---|
date1 | string | number | Date | The first date value to compare |
date2 | string | number | Date | The second date value to compare |
Returns
number
- The number of days between the two date values.