reviewbot

Source code for the is-a.dev r...
Log | Files | Refs | README | LICENSE

numberofdays.js (659B)


      1 /**
      2  * Calculates the number of days between two dates.
      3  *
      4  * @param {string | Date} start - The start date.
      5  * @param {string | Date} end - The end date.
      6  * @returns {number} The number of days between the dates.
      7  */
      8 export function getNumberOfDays(start, end) {
      9     const date1 = new Date(start);
     10     const date2 = new Date(end);
     11 
     12     // One day in milliseconds
     13     const oneDay = 1000 * 60 * 60 * 24;
     14 
     15     // Calculating the time difference between two dates
     16     const diffInTime = date2.getTime() - date1.getTime();
     17 
     18     // Calculating the number of days between two dates
     19     const diffInDays = Math.round(diffInTime / oneDay);
     20 
     21     return diffInDays;
     22 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror