-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclouck.js
25 lines (21 loc) · 1.11 KB
/
clouck.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
element.style.fontSize = '24px'; // 设置字体大小为24像素
// 设置倒计时的目标日期
var countDownDate = new Date("September 6, 2034 00:00:00").getTime();
// 更新倒计时每秒
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
// 计算天、小时、分钟和秒
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// 显示结果
document.getElementById("countdown").innerHTML = days + "天 " + hours + "小时 "
+ minutes + "分钟 " + seconds + "秒 ";
// 如果倒计时结束,显示消息
if (distance < 0) {
clearInterval(x);
document.getElementById("countdown").innerHTML = "活动开始了!";
}
}, 1000);