批改状态:未批改
老师批语:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>2019年农历春节倒计时</title>
<style>
.Spring{width:1000px;height:400px;background-color:blue;margin:0 auto;text-align:center;line-height: 300px;color:#fff;}
</style>
</head>
<body>
<div class="Spring"></div>
<script>
function rmTime(){
//获取当前时间
var date = new Date();
var now = date.getTime();
// 获取春节时间
var str ='2019/02/05 00:00:00';
var endDate = new Date(str);
var end =endDate.getTime();
// 时间差
var tmDate = end - now;
// 剩余天数
var d =Math.floor(tmDate/1000/60/60/24);
// 剩余小时
var h =Math.floor(tmDate/1000/60/60%24);
// 剩余分钟
var m =Math.floor(tmDate/1000/60%60);
// 剩余秒数
var s =Math.floor(tmDate/1000%60);
var Spring = document.getElementsByClassName('Spring')[0];
Spring.innerHTML = ('2019年农历春节倒计时:'+ d+'天'+h +'时' +m + '分' + s + '秒');
//递归每秒用setTimeout()方法,显示动态时间效果
setTimeout('rmTime()',1000);}
rmTime();
</script>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号