Fix age calculation

This commit is contained in:
Elara 2022-02-22 12:18:07 -08:00
parent 6aa28e28ba
commit da49dff76f
1 changed files with 9 additions and 2 deletions

View File

@ -8,7 +8,14 @@ This is a note for anyone using or planning to contribute to ITD. I am {{<raw>}}
{{<raw>}}
<script>
birthday = new Date("April 24, 2005")
document.getElementById("age").innerHTML = (new Date).getFullYear() - birthday.getFullYear()
birthday = new Date("April 24, 2005");
now =new Date();
age = now.getFullYear() - birthday.getFullYear();
if (now.getMonth() < birthday.getMonth()) {
age--;
} else if (now.getMonth() == birthday.getMonth() && now.getDate() < birthday.getDate()) {
age--;
}
document.getElementById("age").innerHTML = age;
</script>
{{</raw>}}