-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (20 loc) · 1.15 KB
/
Copy pathindex.js
File metadata and controls
32 lines (20 loc) · 1.15 KB
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
26
27
28
29
30
31
function formatNumber(number) {
return number < 10 ? `0${number}` : number;
}
// Set the target date for the countdown
const targetDate = new Date('2024-03-25T23:59:59');
setInterval(function(){
const currentDate = new Date();
const remainingTime = targetDate - currentDate;
// Calculate the remaining days, hours, minutes, and seconds
const days = Math.floor(remainingTime / (1000 * 60 * 60 * 24));
const hours = Math.floor((remainingTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60 ));
// 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);
// Update the countdown elements with the remaining time
document.querySelector('.number-day div').innerHTML = formatNumber(days);
document.querySelector('.number-hours div').innerHTML = formatNumber(hours);
document.querySelector('.number-minutes div').innerHTML = formatNumber(minutes);
document.querySelector('.number-seconds div').innerHTML = formatNumber(seconds);
},1000)