utils/ts-src/getDays.ts

13 lines
300 B
TypeScript

/**
* Get number of days between two Date objects
* @param startdate
* @param enddate
*/
export function getDays(startdate: Date, enddate: Date): number {
const startMS = startdate.getTime();
const endMS = enddate.getTime();
return Math.ceil((endMS - startMS) / (24 * 60 * 60 * 1000));
}