鹿晗陪你辞旧迎新:2023 年跨年直播精彩不容错过
【发布时间】:2024-07-31 06:10:31
-
00
-
00
-
00
-
00
<script>
// 获取倒计时元素const daysEl = document.getElementById("days");const hoursEl = document.getElementById("hours");const minutesEl = document.getElementById("minutes");const secondsEl = document.getElementById("seconds");// 设置目标日期和时间const targetDate = new Date("January 1, 2023 00:00:00");// 更新倒计时function updateCountdown() {// 计算剩余时间const now = new Date();const remainingTime = targetDate - now;// 转换剩余时间为天、时、分、秒const days = Math.floor(remainingTime / (1000 60 60 24));const hours = Math.floor((remainingTime % (1000 60 60 24)) / (1000 60 60));const minutes = Math.floor((remainingTime % (1000 60 60)) / (1000 60));const seconds = Math.floor((remainingTime % (1000 60)) / 1000);// 更新倒计时元素daysEl.textContent = days.toString().padStart(2, "0");hoursEl.textContent = hours.toString().padStart(2, "0");minutesEl.textContent = minutes.toString().padStart(2, "0");secondsEl.textContent = seconds.toString().padStart(2, "0");}// 每秒更新倒计时setInterval(updateCountdown, 1000);
</script>