JSFiddle - React, Tailwind, and code Playground
HTML
<p id="count">
</p>
<p id="counth">
</p>
JavaScript
var countDownDate = new Date("Aug 30 2023 18:00").getTime();
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// affichage complet
document.getElementById("count").innerHTML = days + "j " + hours + "h " + minutes + "m " + seconds + "s ";
//affichage partiel
document.getElementById("counth").innerHTML = hours + "h " + minutes + "m " + seconds + "s ";
if (days === 0 && hours === 0 && minutes === 00 && seconds === 00) {
window.location.reload();
}
}, 1000);