Created
March 5, 2019 11:42
-
-
Save eweader/09a14845aaa7d037529ff242d4d29c12 to your computer and use it in GitHub Desktop.
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 (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; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jgwill can you check it