Funktion
Lädt…
Quellcode
<p id="countdown">Lädt...</p>
<script>
// Ziel-Datum festlegen (z. B. 1. Januar 2025)
const targetDate = new Date("2026-01-01T00:00:00").getTime();
function updateCountdown() {
const now = new Date().getTime();
const timeRemaining = targetDate - now;
if (timeRemaining > 0) {
const days = Math.floor(timeRemaining / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeRemaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000);
document.getElementById("countdown").innerText =
`${days} Tage, ${hours} Stunden, ${minutes} Minuten und ${seconds} Sekunden verbleibend.`;
} else {
document.getElementById("countdown").innerText = "Das Datum ist erreicht!";
}
}
// Countdown jede Sekunde aktualisieren
setInterval(updateCountdown, 1000);
</script>
Schreibe einen Kommentar