Weekly Countdown

Countdown to Monday 00:01

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Weekly Countdown</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            margin-top: 20%;
        }
        #countdown {
            font-size: 24px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <h1>Countdown to Monday 00:01</h1>
    <div id="countdown"></div>

    <script>
        function getNextMonday() {
            let now = new Date();
            let daysUntilMonday = (7 - now.getDay()) % 7;
            let nextMonday = new Date(now);
            nextMonday.setDate(now.getDate() + daysUntilMonday);
            nextMonday.setHours(0, 1, 0, 0);
            return nextMonday;
        }

        function updateCountdown() {
            let now = new Date();
            let nextReset = getNextMonday();
            let remainingTime = nextReset - now;
            
            let days = Math.floor(remainingTime / (1000 * 60 * 60 * 24));
            let hours = Math.floor((remainingTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
            let minutes = Math.floor((remainingTime % (1000 * 60 * 60)) / (1000 * 60));
            let seconds = Math.floor((remainingTime % (1000 * 60)) / 1000);
            
            document.getElementById("countdown").innerText = `${days}d ${hours}h ${minutes}m ${seconds}s`;
        }
        
        setInterval(updateCountdown, 1000);
        updateCountdown();
    </script>
</body>
</html>

Skildu eftir svar

Netfang þitt verður ekki birt. Nauðsynlegir reitir eru merktir *