WEBLEB
होम
संपादक
लॉग इन करें
Pro
हिंदी
English
Français
Español
Português
Deutsch
Italiano
हिंदी
क्रिसमस काउंटडाउन HTML टेम्पलेट
84
iroger7
संपादक में खोलें
अपना कोड प्रकाशित करें
अनुशंसित
10 February 2025
HTML CSS लॉगिन फॉर्म कोड
19 October 2024
HTML डेवलपर पोर्टफोलियो V2
23 August 2025
लॉगिन और पंजीकरण फ़ॉर्म HTML/CSS/JS टेम्पलेट
HTML
Copy
Christmas Countdown
Christmas Countdown
0
Days
0
Hours
0
Minutes
0
Seconds
CSS
Copy
body { display: flex; flex-direction: column; align-items: center; justify-content: center; background: #3c3c3c; font-family: Arial, sans-serif; color: #fff; height: 100vh; margin: 0; } h1 { margin-bottom: 20px; font-size: 2.5em; } .countdown { display: flex; gap: 20px; } .time { background: #ff6347; padding: 20px; border-radius: 8px; text-align: center; width: 100px; } .time span { display: block; font-size: 2em; font-weight: bold; } .label { font-size: 1em; margin-top: 5px; }
JS
Copy
const daysEl = document.getElementById('days'); const hoursEl = document.getElementById('hours'); const minutesEl = document.getElementById('minutes'); const secondsEl = document.getElementById('seconds'); function updateCountdown() { const now = new Date(); let currentYear = now.getFullYear(); // Set Christmas date for the current year let christmas = new Date(`December 25, ${currentYear} 00:00:00`); // If today's date is past Christmas, set countdown for next year's Christmas if (now > christmas) { christmas.setFullYear(christmas.getFullYear() + 1); } const diff = christmas - now; const days = Math.floor(diff / (1000 * 60 * 60 * 24)); const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)); const seconds = Math.floor((diff % (1000 * 60)) / 1000); daysEl.textContent = days; hoursEl.textContent = hours; minutesEl.textContent = minutes; secondsEl.textContent = seconds; } // Initial call to display the countdown immediately updateCountdown(); // Update the countdown every second setInterval(updateCountdown, 1000);