REGRESAMOS!!

<!DOCTYPE html>

<html>

<head>

    <title>Reloj de cuenta regresiva</title>

</head>

<body>

    <h1 id="reloj"></h1>

 

    <script>

        // Fecha y hora objetivo

        var objetivo = new Date();

        objetivo.setDate(objetivo.getDate() + (objetivo.getDay() === 1 ? 1 : 2)); // Martes

        objetivo.setHours(12);

        objetivo.setMinutes(0);

        objetivo.setSeconds(0);

 

        // Actualiza el reloj cada segundo

        setInterval(function() {

            var ahora = new Date();

            var diferencia = objetivo.getTime() - ahora.getTime();

 

            // Calcula días, horas, minutos y segundos

            var dias = Math.floor(diferencia / (1000 * 60 * 60 * 24));

            var horas = Math.floor((diferencia % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));

            var minutos = Math.floor((diferencia % (1000 * 60 * 60)) / (1000 * 60));

            var segundos = Math.floor((diferencia % (1000 * 60)) / 1000);

 

            // Muestra el reloj

            document.getElementById("reloj").innerHTML = dias + " días, " + horas + " horas, " + minutos + " minutos, " + segundos + " segundos";

        }, 1000);

    </script>

</body>

</html>

Chat Online