生日倒计时代码
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>生日倒計時</title>
</head>
<body>
<div id="div"></div>
<script type="text/javascript">
window.onload=clock;
function clock(){
var today=new Date(),h=today.getHours(),m=today.getMinutes(),s=today.getSeconds();var stopTime=new Date("2020-08-06 00:00:00"),stopH=stopTime.getHours(),stopM=stopTime.getMinutes(),stopS=stopTime.getSeconds();var shenyu=stopTime.getTime()-today.getTime(),shengyuD=parseInt(shenyu/(60*60*24*1000)),D=parseInt(shenyu)-parseInt(shengyuD*60*60*24*1000),shengyuH=parseInt(D/(60*60*1000)),H=D-shengyuH*60*60*1000,shengyuM=parseInt(H/(60*1000)),M=H-shengyuM*60*1000;S=parseInt((shenyu-shengyuD*60*60*24*1000-shengyuH*60*60*1000-shengyuM*60*1000)/1000)document.getElementById("div").innerHTML=(shengyuD+"天"+shengyuH+"小時"+shengyuM+"分"+S+"秒"+"<br>");setTimeout(clock,1000);
}
</script>
</body>
</html>
?
?
總結
- 上一篇: Codeforces Round #51
- 下一篇: java uuid to long_巧借