1 /**
2 * Returns the days between a start and end date.
3 * @param start initial date
4 * @param end final date
5 * @returns days calculated from two dates
6 */
7 getNumberOfDays(start: string, end: string) {
8 const date1 = new Date(start);
9 const date2 = new Date(end);
10
11 // One day in milliseconds
12 const oneDay = 1000 * 60 * 60 * 24;
13
14 // Calculating the time difference between two dates
15 const diffInTime = date2.getTime() - date1.getTime();
16
17 // Calculating the no. of days between two dates
18 const diffInDays = Math.round(diffInTime / oneDay);
19
20 return diffInDays;
21 }