-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
20 lines (19 loc) · 838 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const days = document.getElementById("days");
const hours = document.getElementById("hours");
const minutes = document.getElementById("minutes");
const seconds = document.getElementById("seconds");
const specialDay = new Date("Nov 11 2022");
function getCountDown() {
const currentDay = new Date();
const countDays = currentDay - specialDay;
console.log(countDays);
const d = Math.floor(countDays / 1000 / 60 / 60 / 24);
const h = Math.floor(countDays / 1000 / 60 / 60) % 24;
const m = Math.floor(countDays / 1000 / 60) % 60;
const s = Math.floor(countDays / 1000) % 60;
days.innerHTML = d + " Ngày";
hours.innerHTML = h.toString().length >= 2 ? h : `0${h}`;
minutes.innerHTML = m.toString().length >= 2 ? m : `0${m}`;
seconds.innerHTML = s.toString().length >= 2 ? s : `0${s}`;
}
setInterval(getCountDown, 1000);