01、效果图

02、应用
new Date()//返回今天日期
new Date("April 1,2025")//返回目标日期
document.write()//文档显示
getTime()返回当日毫秒数
Math.floor(amadays / (1000 * 60 * 60 * 24)//把毫秒换算天
03、代码
html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<script>
var aim= new Date("April 1,2025");
var aimday="愚人节";
var today = new Date();
var amadays = aim.getTime() - today.getTime();
var remain = Math.floor(amadays / (1000 * 60 * 60 * 24)); //把毫秒换算天
if (remain >= 0) ;
document.write("现在离2025年"+aimday+"还有: <font color=red><b>"+remain +"</b></font>天"+"<br>");
document.write(aim+"<br>");//返回目标日期
document.write(today+"<br>");//返回今天日期
document.write( aim.getTime()+"<br>");//返回目标日期毫秒数
document.write(today.getTime()+"<br>");//返回当日毫秒树木数 document.write(amadays+"<br>");
document.write(remain+"<br>");//返回今日与目标日的差值
</script>
<body>
</body>
</html>