Added age.js to allow for automatic age update
This commit is contained in:
10
js/age.js
Normal file
10
js/age.js
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user