Fix age calculation
This commit is contained in:
parent
6aa28e28ba
commit
da49dff76f
@ -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>}}
|
Loading…
Reference in New Issue
Block a user