Created
September 18, 2012 20:47
-
-
Save egermano/3745791 to your computer and use it in GitHub Desktop.
Get Day Delta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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