倒计时
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p>距离活动结束时间还有:</p>
<p id="restTime"></p>
<script>
setInterval(function () {
var dateTime=countDown();
var restTime=document.getElementById('restTime')
restTime.innerHTML=dateTime;
},1000);
function countDown() {
var setTime=new Date('2019/08/05 10:00:00');
var nowTime=new Date();
var rest=setTime.getTime()-nowTime.getTime();
var day=parseInt(rest/1000/60/60/24);
var hour=parseInt(rest/1000/60/60%24);
var minute=parseInt(rest/1000/60%60);
var second=parseInt(rest/1000%60);
var myDate=day+"日"+hour+"时"+minute+"分"+second+"秒";
return myDate;
}
</script>
</body>
</html>