Answers for "how to get all array of data between two dates in javascript"

0

get the difference between two dates js

const date1 = new Date('7/13/2010');
const date2 = new Date('12/15/2010');
const diffTime = Math.abs(date2 - date1);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); 
console.log(diffTime + " milliseconds");
console.log(diffDays + " days");
Posted by: Guest on November-13-2020
0

get different date from two date javascript

/**
   * Returns the days between a start and end date.
   * @param start initial date
   * @param end final date
   * @returns days calculated from two dates
   */
  getNumberOfDays(start: string, end: string) {
    const date1 = new Date(start);
    const date2 = new Date(end);

    // One day in milliseconds
    const oneDay = 1000 * 60 * 60 * 24;

    // Calculating the time difference between two dates
    const diffInTime = date2.getTime() - date1.getTime();

    // Calculating the no. of days between two dates
    const diffInDays = Math.round(diffInTime / oneDay);

    return diffInDays;
  }
Posted by: Guest on September-18-2021

Code answers related to "how to get all array of data between two dates in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language