I have a js countdown with php fucntion inside a js condition. Evething is good except that when reloading the page the php fucntion runs anyway.
var countDownDate = new Date("2020/04/25 16:15:25").getTime();
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
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);
document.getElementById("demo").innerHTML = hours + "h " + minutes + "m " + seconds + "s ";
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "SESSION EXPIRED";
<?php block_user(2); ?>
document.getElementById("demo2").innerHTML = "User 2 blocked";
}
}, 1000);