Skip to content

Instantly share code, notes, and snippets.

@buiquangduc
Created October 7, 2017 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buiquangduc/fb5bc343f2ee683fa85f165944aab9d5 to your computer and use it in GitHub Desktop.
Save buiquangduc/fb5bc343f2ee683fa85f165944aab9d5 to your computer and use it in GitHub Desktop.
Get the range from date to date with Javascript
var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var firstDate = new Date(2008,01,12);
var secondDate = new Date(2008,01,22);
var diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment