<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<script type="text/javascript" luanguange>
window.onload = function(){
jishi();
}
function li(i){
if(i<10){
i= '0'+i;
}
return i;
}
function jishi(){
var shijian = new Date();//当前时间
var jieshu = new Date('2220/9/15,00:00:00');//结束时间
var shijiancha=parseInt((jieshu.getTime()-shijian.getTime())/(1000));//得出的是总共还剩下多少毫秒
var t = parseInt(shijiancha/(24*60*60));//还剩几天
var x = parseInt(shijiancha/(60*60)%24);//还剩几小时
var f = parseInt(shijiancha/60%60);
var m = parseInt(shijiancha%60);
t = li(t);
x = li(x);
f = li(f);
m = li(m);
// shijiancha/24*60*60*1000
document.getElementById('sj').innerHTML =t+'天'+x+'小时'+f+'分钟'+m+'秒';
setTimeout(jishi,500);
}
</script>
<style type="text/css">
body{
margin: 0;
padding: 0;
background-color: rgb(240,240,240);
}
#ss{
width: 800px;
height: 440px;
background-color: rgb(81,182,176);
margin: auto;
border-radius: 50px;
text-align: center;
color: #ffffff;
margin-top: 70px;
padding-top: 60px;
line-height: 90px;
font-family: '微软雅黑';
border: 5px solid #ffffff;
}
p{
font-size: 40px;
}
#sj{
font-size:60px;
font-family: 'Arial';
}
</style>
<body>
<div id="ss">
<p>距离中秋节还剩下:</p>
<span id="sj"></span>
</div>
</body>
</html>
来自:http://www.qdfuns.com/notes/id/all:all:all:82dec52c2ad6cd55dc2a84ee5cfdc713/page/20.html