倒计时效果

倒计时效果:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>倒计时效果</title>
</head>
<body>
	<div>倒计时:<span id="show"></span></div>
	<script>
	setInterval(function() {
		var endTime = new Date('2020/9/15,00:00:00');//设置结束时间
		var curTime = new Date();
		var leftTime = parseInt((endTime.getTime() - curTime.getTime()) / 1000);//得出秒
		// console.log(leftTime);
		var date = parseInt(leftTime / (24 * 60 * 60));
		var hours = parseInt(leftTime / (60 * 60) % 24);
		var minutes = parseInt(leftTime / 60 % 60);
		var seconds = parseInt(leftTime % 60);
		var show = document.getElementById('show');
		show.innerHTML = date + '天' + hours + '小时' + minutes + '分钟' + seconds + '秒';
	}, 1);
	</script>
</body>
</html>

  

posted @ 2016-09-10 17:10  HandsomeHan  阅读(201)  评论(0编辑  收藏  举报