jsはタイムスタンプを設定し、カウントダウンを行います.イベント終了時間など
1423 ワード
js
function countTime() {
//
var date = new Date();
var now = date.getTime();
//
var str="2017/5/17 00:00:00";
var endDate = new Date(str);
var end = endDate.getTime();
//
var leftTime = end-now;
// d,h,m,s
var d,h,m,s;
if (leftTime>=0) {
d = Math.floor(leftTime/1000/60/60/24);
h = Math.floor(leftTime/1000/60/60%24);
m = Math.floor(leftTime/1000/60%60);
s = Math.floor(leftTime/1000%60);
}
// div
document.getElementById("_d").innerHTML = d+" ";
document.getElementById("_h").innerHTML = h+" ";
document.getElementById("_m").innerHTML = m+" ";
document.getElementById("_s").innerHTML = s+" ";
// countTime ,
setTimeout(countTime,1000);
}
00
00
00
00