登录:装备,密码,短信登录
This commit is contained in:
@@ -93,4 +93,24 @@ export function getTodayZeroDate() {
|
||||
date.setMinutes(0);
|
||||
date.setSeconds(0);
|
||||
return date;
|
||||
}
|
||||
|
||||
export function getAge(birthday: string) {
|
||||
let d = new Date(birthday + ' 00:00:00');
|
||||
let _year = d.getFullYear();
|
||||
let _month = d.getMonth() + 1;
|
||||
let _day = d.getDate();
|
||||
|
||||
let age = 0;
|
||||
let now = new Date();
|
||||
let year = now.getFullYear();
|
||||
let month = now.getMonth() + 1;
|
||||
let day = now.getDate();
|
||||
|
||||
if (year >= _year && month >= _month && day >= _day) {
|
||||
age = year - _year;
|
||||
}else{
|
||||
age = year - _year - 1;
|
||||
}
|
||||
return age
|
||||
}
|
||||
Reference in New Issue
Block a user