-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
22 lines (20 loc) · 1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const countdownDate = new Date("September 02, 2023 12:00:00").getTime();
function formatTime(time) {
return time < 10 ? "0" + time : time;
}
const countdown = setInterval(function() {
const now = new Date().getTime();
const timeRemaining = countdownDate - now;
const days = Math.floor(timeRemaining / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeRemaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000);
let displayDays = formatTime(days);
let displayHours = formatTime(hours);
let displayMinutes = formatTime(minutes);
let displaySeconds = formatTime(seconds);
document.querySelector('.day').textContent = displayDays;
document.querySelector('.hour').textContent = displayHours;
document.querySelector('.minute').textContent = displayMinutes;
document.querySelector('.second').textContent = displaySeconds;
}, 1000);