我的任务是显示从当前日期到存储在mysql字段中的日期的倒计时。我用while循环获取结果与PHP。显示结果没有问题,但是我需要将每个函数实现到我的jQuery代码的帮助。
<p id="demo"></p>
<script>
var countDownDate = new Date("03.29.2019 18:00:00").getTime();
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
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);
document.getElementById("demo").innerHTML = hours + "ч "
+ minutes + "м " + seconds + "с ";
});
</script>