Widget:CountdownStore

From Dreamlight Valley Wiki
Jump to navigation Jump to search

<script> (function() {

 // Function to update the store countdown
 function updateStoreCountdown() {
   var now = new Date();
   var targetHour = 8;
   var targetDate = new Date(now);
   targetDate.setUTCHours(targetHour, 0, 0, 0);
   if (now > targetDate) {
     targetDate.setDate(targetDate.getDate() + 1);
   }
   var timeDifference = targetDate - now;
   var seconds = Math.floor(timeDifference / 1000);
   var minutes = Math.floor(seconds / 60);
   var hours = Math.floor(minutes / 60);
   var formattedCountdown = ('0' + hours % 24).slice(-2) + ':' +
                            ('0' + minutes % 60).slice(-2) + ':' +
                            ('0' + seconds % 60).slice(-2);
   document.getElementById('countdown-store').innerHTML = formattedCountdown;
   // Use a separate setTimeout for store countdown
   setTimeout(updateStoreCountdown, 1000);
 }
 updateStoreCountdown();

})(); </script>