Added age.js to allow for automatic age update

This commit is contained in:
2022-04-28 18:18:49 +01:00
parent 189ca5034b
commit 87b2e808f7
2 changed files with 18 additions and 8 deletions

10
js/age.js Normal file
View File

@ -0,0 +1,10 @@
function getAge(dateString) {
var today = new Date();
var birthDate = dateString;
var age = today.getFullYear() - birthDate.getFullYear();
var m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
return age;
}