-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
23 lines (18 loc) · 868 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const countdown = () => {
const countDate = new Date("March 13, 2022 10:00:00").getTime();
const now = new Date().getTime();
const remainingTime = countDate - now;
const second = 1000;
const minute = second * 60;
const hour = minute * 60;
const day = hour * 24;
const textDay = Math.floor(remainingTime / day);
const textHour = Math.floor((remainingTime % day) / hour);
const textMinute = Math.floor((remainingTime % hour) / minute);
const textSecond = Math.floor((remainingTime % minute) / second);
document.querySelector(".day").innerText = textDay > 0 ? textDay : 0;
document.querySelector(".hour").innerText = textHour > 0 ? textHour : 0;
document.querySelector(".minute").innerText = textMinute > 0 ? textMinute : 0;
document.querySelector(".second").innerText = textSecond > 0 ? textSecond : 0;
};
setInterval(countdown, 500);