Widget:CountdownPremium
Jump to navigation
Jump to search
<script> (function() {
// Function to update the premium countdown function updatePremiumCountdown() { var currentDate = new Date(); var targetDay = 3; var targetHour = 14; // Adjusted to 2pm UTC (14:00)
var nextWednesday = new Date(currentDate); nextWednesday.setUTCHours(targetHour, 0, 0, 0);
// If today is Wednesday and the target hour has passed, move to the next Wednesday if (currentDate.getUTCDay() === targetDay && currentDate.getUTCHours() >= targetHour) { nextWednesday.setDate(nextWednesday.getDate() + 7); }
while (nextWednesday.getUTCDay() !== targetDay) { nextWednesday.setDate(nextWednesday.getDate() + 1); }
var timeDifference = nextWednesday - currentDate;
if (timeDifference < 0) { nextWednesday.setDate(nextWednesday.getDate() + 7); timeDifference = nextWednesday - currentDate; }
var days = Math.floor(timeDifference / (24 * 60 * 60 * 1000)); var hours = Math.floor((timeDifference % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000)); var minutes = Math.floor((timeDifference % (60 * 60 * 1000)) / (60 * 1000)); var seconds = Math.floor((timeDifference % (60 * 1000)) / 1000);
var countdownText = ;
if (timeDifference <= 24 * 60 * 60 * 1000) { // When less than or equal to 24 hours remain, format as HH:MM:SS countdownText = ('0' + hours).slice(-2) + ':' + ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2); } else { // Else, continue with the original format if (days > 0) { countdownText += days + 'd '; }
countdownText += ('0' + hours).slice(-2) + 'h ' + ('0' + minutes).slice(-2) + 'm'; }
document.getElementById('countdown-premium').innerHTML = countdownText;
// Use a separate setTimeout for premium countdown setTimeout(updatePremiumCountdown, 1000); }
window.onload = function() { updatePremiumCountdown(); };
})(); </script>