<script> // 开启定时器 setInterval(conuntDown, 1000); //每隔一秒刷新一次 function conuntDown(time) { var nowTime = +new Date(); // 返回的是当前时间总的毫秒数 var inputTime = +new Date(time) var times = (inputTime - nowTime) / 1000; //time是剩余时间总的秒数 var h = parseInt((times / 60 / 60) % 24); h = h < 10 ? "0" + h : h; var m = parseInt((times / 60) % 60); m = m < 10 ? "0" + m : m; var s = parseInt(times % 60); s = s < 10 ? "0" + s : s; return h +'时'+ m+'分' + s+'秒' } console.log(conuntDown('2023-2-8 10:40:00')); var date =new Date() console.log(date); </script>
标签:60,Date,10,times,倒计时,parseInt,var From: https://www.cnblogs.com/0722tian/p/17100918.html