Skip to content

Instantly share code, notes, and snippets.

@iansym
Created October 8, 2010 15:28
Show Gist options
  • Save iansym/616970 to your computer and use it in GitHub Desktop.
Save iansym/616970 to your computer and use it in GitHub Desktop.
Simple age calculation function
function calcAge(YYYY,MM,DD) {
var today = new Date(),
todayYYYY = today.getFullYear(),
todayMM = today.getMonth() + 1,
todayDD = today.getDate();
return (todayYYYY - YYYY) - (todayMM < MM || (todayMM == MM && todayDD < DD) ? 1 : 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment