Commit 23c58297 authored by 华国豪's avatar 华国豪 🙄

格式化年龄

parent 6347d589
......@@ -802,14 +802,15 @@
jsGetAge(strBirthday){
let returnAge;
let strBirthdayArr=strBirthday.split("-");
let birthYear = strBirthdayArr[0];
let birthMonth = strBirthdayArr[1];
let birthDay = strBirthdayArr[2];
let birthYear = Number(strBirthdayArr[0]);
let birthMonth = Number(strBirthdayArr[1]);
let birthDay = Number(strBirthdayArr[2]);
let d = new Date();
let nowYear = d.getFullYear();
let nowMonth = d.getMonth() + 1;
let nowDay = d.getDate();
if(nowYear == birthYear && birthMonth <= nowMonth && birthDay <= nowDay){
console.log(birthYear)
if(nowYear === birthYear){
returnAge = 1;//同年 则为0岁
} else {
let ageDiff = nowYear - birthYear ; //年之差
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment