1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| function show(times) { var time = Number(new Date(times)); var nowTime = Date.now(); var timediff = Math.round((time - nowTime) / 1000); if (timediff <= -1) { return; } var day = parseInt(timediff / 3600 / 24); var hour = parseInt(timediff / 3600 % 24); var minute = parseInt(timediff / 60 % 60); var second = timediff % 60; document.getElementById("1").innerHTML = day; document.getElementById("2").innerHTML = hour; document.getElementById("3").innerHTML = minute; document.getElementById("4").innerHTML = second; setTimeout(show, 1000);
} show("2019-1-8 17:33:0")
|
评论加载中