js通过身份证计算年龄

js通过身份证计算年龄

export const discriCard = (UUserCard) => {
	(UUserCard + '' ).substring(6, 10) + "-" + (UUserCard + '' ).substring(10, 12) + "-" + (UUserCard + '' ).substring(12, 14)
	//获取年龄 
	var myDate = new Date();
	var month = myDate.getMonth() + 1;
	var day = myDate.getDate()
	var age = myDate.getFullYear() - (UUserCard + '' ).substring(6, 10) - 1
	if ((UUserCard + '' ).substring(10, 12) < month || (UUserCard + '' ).substring(10, 12) == month && (UUserCard + '' ).substring(12, 14) <= day) {
	    age++
	}
	return age
}

上一篇:抖音上火的时钟


下一篇:Js获取当前日期时间及其它操作