Skip to content

Instantly share code, notes, and snippets.

@pawiromitchel
Created January 27, 2017 11:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawiromitchel/72b87cd5ed51704423e596c8f074e594 to your computer and use it in GitHub Desktop.
Save pawiromitchel/72b87cd5ed51704423e596c8f074e594 to your computer and use it in GitHub Desktop.
JS - Calculate the difference between 2 dates
function daysBetween(one, another) {
return Math.round(Math.abs(one - another) / 8.64e7);
}
// usage
a = daysBetween(new Date(date1), new Date(date2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment