You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
335 B
18 lines
335 B
4 years ago
|
export function age() {
|
||
|
let birthdate = new Date(2002, 8, 29)
|
||
|
let now = new Date()
|
||
|
|
||
|
let age = now.getFullYear() - birthdate.getFullYear()
|
||
|
|
||
|
if (now.getMonth() < birthdate.getMonth()) {
|
||
|
age--
|
||
|
}
|
||
|
if (
|
||
|
birthdate.getMonth() === now.getMonth() &&
|
||
|
now.getDate() < birthdate.getDate()
|
||
|
) {
|
||
|
age--
|
||
|
}
|
||
|
return age
|
||
|
}
|