js実現のカウントダウン
940 ワード
function countDown(year,month,day,hour,minute,second){
// month-1 ,
var d1 = new Date(year,month-1,day,hour,minute,second);
var d2 = new Date();
//
var millisecond1 = d1.getTime();
var millisecond2 = d2.getTime();
if(millisecond1 <= millisecond2){
alert(" , !");
}else{
var intervalTime = (millisecond1 - millisecond2) / 1000;
var hour1 = parseInt(intervalTime / 3600);
var minute1 = parseInt((intervalTime - hour1*3600) / 60);
var second1 = parseInt(intervalTime - hour1*3600 - minute1*60);
var str = hour1+" "+minute1+" "+second1+" ";
}
return str;
}
var oDiv = document.getElementById("div1");
setInterval(function(){
oDiv.innerHTML = " :"+countDown(2018,9,8,14,30,20);
},1000)