<div id="time"></div> <script> var aim=new Date('2022/11/11') setInterval(function(){ var date=new Date() var sub=Math.ceil((aim-date)/1000) var day=parseInt(sub/(60*60*24)) var hour=parseInt((sub/(60*60))%24) var minute=parseInt((sub/60)%60) var seconds=sub%60 var str="距离双11还有"+day+"天"+hour+"时"+minute+"分"+seconds+"秒" time.innerHTML=str },1000) </script>
复制
运行结果: