<body>
<h1>距离1212还剩:</h1>
<p></p>
<script>
setInterval(function() {
var end_time = Math.floor((new Date("2018/01/01 00:00:00")).getTime() / 1000), //目标结束时间
now_time = Math.floor((new Date()).getTime() / 1000), //此刻时间
differen_time = (end_time - now_time); //目标结束时间到此刻时间差
var day = Math.floor(differen_time / 86400); //剩余天数 86400为一天的秒数
var hour = Math.floor(differen_time % 86400 / 3600); //剩余小时
var min = Math.floor(differen_time % 86400 % 3600 / 60); //剩余分钟
var second = Math.floor(differen_time % 86400 % 3600 % 60); //剩余秒
var p = document.querySelector("p");
p.innerHTML = day + "天" + hour + "小时" + min + "分" + second + "秒";
}, 1000)
</script>
</body>