Skip to content

Instantly share code, notes, and snippets.

@egermano
Created September 18, 2012 20:47
Show Gist options
  • Save egermano/3745791 to your computer and use it in GitHub Desktop.
Save egermano/3745791 to your computer and use it in GitHub Desktop.
Get Day Delta
function getDayDelta(incomingYear,incomingMonth,incomingDay){
var incomingDate = new Date(incomingYear,incomingMonth-1,incomingDay),
today = new Date(), delta;
// EDIT: Set time portion of date to 0:00:00.000
// to match time portion of 'incomingDate'
today.setHours(0);
today.setMinutes(0);
today.setSeconds(0);
today.setMilliseconds(0);
// Remove the time offset of the current date
today.setHours(0);
today.setMinutes(0);
delta = today - incomingDate;
return Math.round(delta / 1000 / 60 / 60/ 24);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment