【JS】简易高考倒计时

Osinghong2个月前 (04-27)成果展示60
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>d24c04429</title>
</head>
<body>
    <script>
        function getDate() {
            var now = new Date();
            var targetDate = new Date("2025-06-06T08:00:00+08:00");
            var time = targetDate - now;
            var days = Math.floor(time / (1000 * 60 * 60 * 24));
            var hours = Math.floor((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
            var minutes = Math.floor((time % (1000 * 60 * 60)) / (1000 * 60));
            var seconds = Math.floor((time % (1000 * 60)) / 1000);
            document.body.innerHTML = "距离高考还剩: " + days + "天" + hours + "小时" + minutes + "分钟" + seconds + "秒";
        }
        function myTimer(){
            setInterval(getDate, 50);
        }
        myTimer();
    </script>
</body>
</html>


打赏
分享给朋友:

相关文章

【H5】表单7个月前 (11-27)
【H5】小米导航栏6个月前 (12-05)
【JS】For语句练习3个月前 (03-17)
【JS】For语句进阶3个月前 (03-24)
【JS】关于continue3个月前 (03-24)