Skip to content

Instantly share code, notes, and snippets.

@yonatansnir
Last active October 11, 2020 11:28
Show Gist options
  • Save yonatansnir/4ac480aa0bfda5e222edbf1780caafbd to your computer and use it in GitHub Desktop.
Save yonatansnir/4ac480aa0bfda5e222edbf1780caafbd to your computer and use it in GitHub Desktop.
Calculate Days Between Two Dates.
function daysBetween(date1, date2){
const oneDayInMs = 1000*60*60*24;
let diffInMs = Math.abs(date1.getTime() - date2.getTime())
let result = diffInMs / oneDayInMs;
return Math.floor(result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment