Skip to content

Instantly share code, notes, and snippets.

@eweader
Created March 5, 2019 11:42
Show Gist options
  • Save eweader/09a14845aaa7d037529ff242d4d29c12 to your computer and use it in GitHub Desktop.
Save eweader/09a14845aaa7d037529ff242d4d29c12 to your computer and use it in GitHub Desktop.
function (birthMonth, birthDay, birthYear) {
var todayDate = new Date(),
todayYear = todayDate.getFullYear(),
todayMonth = todayDate.getMonth(),
todayDay = todayDate.getDate(),
age = todayYear - birthYear.date;
if (todayMonth < birthMonth.date - 1) {
age--;
}
if (birthMonth.date - 1 === todayMonth && todayDay < birthDay.date) {
age--;
}
return $scope.age = age;
};
@eweader
Copy link
Author

eweader commented Mar 5, 2019

@jgwill can you check it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment