function timeCount() {
var tar = new Date('2018/7/22 18:30:00').getTime();
var now = new Date().getTime();
var time = tar - now;
if(time <= 0){
clearInterval(timer2);
time = 0;
}
var h = Math.floor(time/3600000);
time = time - h*3600000;
var m = Math.floor(time/60000);
time = time - m*60000;
var s = Math.floor(time/1000);
var str = `距离下课还有${h<10?'0'+h:h}小时${m<10?'0'+m:m}分钟${s<10?'0'+s:s}秒`;
var oDiv = document.getElementById('div1');
oDiv.innerText = str;
}
var timer2 = setInterval(function () {
timeCount();
},1000);