38 lines
1.3 KiB
HTML
38 lines
1.3 KiB
HTML
<p id="serverResetTimer"></p>
|
|
<script>
|
|
// Set the date we're counting down to
|
|
const countDownDate = new Date("January 1, 2021 20:00:00").getTime();
|
|
const active = false;
|
|
|
|
// Update the count down every 1 second
|
|
if (active) {
|
|
const x = setInterval(function () {
|
|
|
|
// Get today's date and time
|
|
const now = new Date().getTime();
|
|
|
|
// Find the distance between now and the count down date
|
|
const distance = countDownDate - now;
|
|
|
|
// Time calculations for days, hours, minutes and seconds
|
|
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
|
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
|
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
|
|
|
// Display the result in the element with id="demo"
|
|
document.getElementById("serverResetTimer").innerHTML = days + "d " + hours + "h "
|
|
+ minutes + "m " + seconds + "s ";
|
|
|
|
// If the count down is finished, write some text
|
|
if (distance < 0) {
|
|
clearInterval(x);
|
|
document.getElementById("serverResetTimer").innerHTML = "EXPIRED";
|
|
}
|
|
}, 1000);
|
|
}
|
|
else{
|
|
document.getElementById("serverResetTimer").innerHTML = "Timer canceled"
|
|
}
|
|
</script>
|