<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
div {
width: 1210px;
margin: 200px auto;
color: red;
text-align: center;
font: 600 30px/30px "simsun";
}
</style>
</head>
<body>
<div></div>
<script>
var div=document.getElementsByTagName("div")[0];
var timer = setInterval(fn,1);
function fn(){
var nowtime = new Date();
var future = new Date("2019/09/05 18:23:15");
var timeSum = future.getTime() - nowtime.getTime();
var day = parseInt(timeSum/1000/60/60/24);
var hour = parseInt(timeSum/1000/60/60%24);
var minu = parseInt(timeSum/1000/60%60);
var sec = parseInt(timeSum/1000%60);
var millsec = parseInt(timeSum%1000);
day=day<10?"0"+day:day;
hour=hour<10?"0"+hour:hour;
minu=minu<10?"0"+minu:minu;
sec=sec<10?"0"+sec:sec;
if(millsec<10){
millsec="00"+millsec;
}else if(millsec<100){
millsec="0"+millsec;
}
//
// console.log(day);
// console.log(parseInt(timeSum/1000/60/60/24));
if(timeSum<0){
div.innerHTML="距离苹果发布会还有00天00小时00分00秒000毫秒";
clearInterval(timer);
return;
}
div.innerHTML="距离苹果发布会还有"+day+"天"+hour+"小时"+minu+"分"+sec+"秒"+millsec+"毫秒";
}
</script>
</body>
</html>
time
网友评论