Skip to content

Instantly share code, notes, and snippets.

@karlpokus
Last active May 31, 2016 12:56
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 karlpokus/c1771066f83d15c4ca07 to your computer and use it in GitHub Desktop.
Save karlpokus/c1771066f83d15c4ca07 to your computer and use it in GitHub Desktop.
Number of days between two dates
function dayDiff(f, s, abs){
var f = new Date(f),
s = new Date(s),
oneDay = 24*60*60*1000;
if (abs) {
return Math.round(Math.abs((f.getTime() - s.getTime())/(oneDay)));
} else {
return Math.round((f.getTime() - s.getTime())/(oneDay));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment