JS obtain the difference between the two dates (in days)

const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
  (dateFinal - dateInitial) / (1000 * 3600 * 24);

// 事例
getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')); // 9

 

Guess you like

Origin www.cnblogs.com/wkk2020/p/12515133.html