Follow along with the video below to see how to install our site as a web app on your home screen.
ملاحظة: This feature may not be available in some browsers.
<div id="countdown">جاري التحميل ...</div>
<script>
function updateCountdown() {
const now = new Date();
const nextYear = now.getFullYear() + 1;
const newYearDate = new Date(`January 1, ${nextYear} 00:00:00`);
const diff = newYearDate - now;
if (diff <= 0) {
document.getElementById('countdown').textContent = "Happy New Year!";
clearInterval(intervalId);
return;
}
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);
document.getElementById('countdown').textContent =
`${days} Days ${hours} Hours ${minutes} Minutes ${seconds} Seconds`;
}
const intervalId = setInterval(updateCountdown, 1000);
updateCountdown();
</script>
<div id="countdown" style="text-align: center; font-size: 1.5em;"></div>
#countdown div {
display: inline-block;
margin: 0 10px;
text-align: center;
}
#countdown span {
font-weight: bold;
font-size: 2em;
color: #ff5733;
}
// JavaScript Code for New Year Countdown 2024
(function countdownToNewYear() {
// Set the target date to New Year 2024
const targetDate = new Date("January 1, 2024 00:00:00").getTime();
// Function to update the countdown
function updateCountdown() {
const now = new Date().getTime(); // Get the current time
const timeLeft = targetDate - now; // Calculate the difference
if (timeLeft <= 0) {
// If the countdown has ended
document.getElementById("countdown").innerHTML = "🎉 Happy New Year 2024! 🎉";
clearInterval(timerInterval); // Stop updating the timer
return;
}
// Calculate days, hours, minutes, and seconds remaining
const days = Math.floor(timeLeft / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeLeft % (1000 * 60)) / 1000);
// Display the countdown
document.getElementById("countdown").innerHTML = `
<div><span>${days}</span> Days</div>
<div><span>${hours}</span> Hours</div>
<div><span>${minutes}</span> Minutes</div>
<div><span>${seconds}</span> Seconds</div>
`;
}
// Update the countdown every second
const timerInterval = setInterval(updateCountdown, 1000);
// Initial call to display immediately
updateCountdown();
})();
// Add this to your XenForo template with a container for the countdown
// Example HTML to include in your XenForo template:
// <div id="countdown" style="text-align: center; font-size: 1.5em;"></div>
<!-- Add this code to a XenForo widget or template -->
<div id="countdown-container" style="text-align: center; font-size: 2em; padding: 20px;">
<h2>Countdown to New Year 2025</h2>
<div id="countdown">
<span id="days">00</span> days
<span id="hours">00</span> hours
<span id="minutes">00</span> minutes
<span id="seconds">00</span> seconds
</div>
</div>
<script>
// Countdown script for New Year 2025
(function () {
const targetDate = new Date('January 1, 2025 00:00:00').getTime();
function updateCountdown() {
const now = new Date().getTime();
const timeLeft = targetDate - now;
if (timeLeft < 0) {
document.getElementById('countdown').innerHTML = '🎉 Happy New Year 2025! 🎉';
return;
}
const days = Math.floor(timeLeft / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeLeft % (1000 * 60)) / 1000);
document.getElementById('days').textContent = days.toString().padStart(2, '0');
document.getElementById('hours').textContent = hours.toString().padStart(2, '0');
document.getElementById('minutes').textContent = minutes.toString().padStart(2, '0');
document.getElementById('seconds').textContent = seconds.toString().padStart(2, '0');
}
// Update countdown every second
setInterval(updateCountdown, 1000);
updateCountdown(); // Initial call to avoid delay
})();
</script>
بارك الله فيك وماقصرتاخي للبرمجة والتكويد انصحك باستخدام claude.ai فهو افضل من gpt من هذه الناحية