我的年龄倒计时
// 用户出生日期
var birthDate=new Date('1995-12-15T00:00:00');
function updateAge() {
var currentDate=new Date();
var ageInMilliseconds=currentDate - birthDate;
var ageInSeconds=Math.floor(ageInMilliseconds / 1000);
var ageInMinutes=Math.floor(ageInSeconds / 60);
var ageInHours=Math.floor(ageInMinutes / 60);
var ageInDays=Math.floor(ageInHours / 24);
var ageInMonths=Math.floor(ageInDays / 30.44);
var ageInYears=Math.floor(ageInMonths / 12);
var remainingMonths=ageInMonths % 12;
var remainingDays=ageInDays % 30.44;
var ageString=`年龄:${ageInYears}年 ${remainingMonths}个月 ${Math.floor(remainingDays)}天`;
document.getElementById("countdown").textContent=ageString;
}
setInterval(updateAge, 1000);
微信扫一扫打赏
支付宝扫一扫打赏

