calculate the days between two dates

PHOTO EMBED

Sun Sep 25 2022 07:35:16 GMT+0000 (UTC)

Saved by @Kristi #javascript

const calcDaysPassed = (date1, date2) =>
  Math.round(Math.abs((date2 - date1) / (1000 * 60 * 60 * 24)));

const day1 = calcDaysPassed(new Date(2037, 3, 14), new Date(2037, 3, 24));

//(1000 * 60 * 60 * 24) 1000milliseconds/sec 60sec/min 60min/hour 24hours/day
//Math.abs we use so that it doesn't matter which date is used first (remove -)
//Math.floor to remove decimals that occur if hours and minutes are included
content_copyCOPY