-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
26 lines (22 loc) · 1.07 KB
/
script.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
26
// Countdown Timer Logic
function updateCountdown() {
const newYearDate = new Date('2025-01-01T00:00:00');
const currentDate = new Date();
const timeDifference = newYearDate - currentDate;
if (timeDifference > 0) {
const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeDifference % (1000 * 60)) / 1000);
document.getElementById('countdown').textContent = `${days} days:${hours} hours:${minutes} minutes:${seconds} seconds`;
} else {
document.getElementById('countdown').textContent = "00:00:00:00";
}
}
// Handle Preview Button
document.getElementById('previewButton').addEventListener('click', function () {
document.getElementById('previewMessage').textContent = "Happy New Year 2025 !";
});
// Update countdown every second
setInterval(updateCountdown, 1000);
updateCountdown();