<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="time"></div>
</body>
<script>
window.onload=function(){
setInterval(function(){
var dqtime = new Date(); /* 获取当前日期*/
var wltime = new Date("2022-9-9 24:00:00");/* 指定日期 */
var fetch = parseInt((wltime.getTime() - dqtime.getTime()) / 1000);/*fetch 获取 */
var t = parseInt(fetch / 3600 / 24);/* 天 */
var x = parseInt(fetch / 3600 % 24);/* 小时 */
var f = parseInt(fetch / 60 % 60);/* 分钟 */
var m = parseInt(fetch % 60);/* 秒 */
document.getElementById("time").innerHTML="距离中秋节还有" + t + "天" + x + "小时" + f +"分钟" + m +"秒";/* 拼串 */
},1000);
}
</script>
</html>
04-12
681
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-12