7 Day Repeat Countdown Timer

HTML Code:

				
					<style>
  #countdown {
    font-size: 36px;
    font-weight: bold;
    color: white;
    text-align: center;
    margin: 20px 0;
  }
</style>

<p id="countdown"></p>

<script>
  function updateCountdown() {
    let startTime = new Date("2023-02-28T15:22:00");
    const currentTime = new Date();
    let diffTime = startTime - currentTime;
    let totalSeconds = diffTime / 1000;

    while (totalSeconds <= 0) {
      startTime.setDate(startTime.getDate() + 7);
      diffTime = startTime - currentTime;
      totalSeconds = diffTime / 1000;
    }

    const days = Math.floor(totalSeconds / (24 * 60 * 60));
    const hours = Math.floor((totalSeconds % (24 * 60 * 60)) / (60 * 60));
    const minutes = Math.floor((totalSeconds % (60 * 60)) / 60);
    const seconds = Math.floor(totalSeconds % 60);

    document.getElementById("countdown").innerHTML = `${days}d ${hours}h ${minutes}m ${seconds}s`;
  }

  setInterval(updateCountdown, 1000);
</script>

				
			
alt="tutorials" alt="Hexagon Portfolio Code" alt="GLOWING NEON TEXT" alt="Water Ripple Effect " alt="Water Ripple Effect code" alt="Rotate And Z-Index" alt="Not Linktree" alt="User IP and Location" alt="auto play video" alt="Click Button to Change Image And Text Using Elementor" alt="7 Day Repeat Countdown Timer" alt="Blog Posts Only" alt="Change Background And Text Colour On Scroll Code"