宝宝就快出生了,闲着无聊,写个小东西玩玩
1 <html>
2 <head>
3 <style>
4 #PPQTime{
5 font-size:36px;
6 color:black;
7 font-weight:bold;
8 }
9
10 </style>
11 <script>
12
13 function Clock()
14 {
15 var Today=new Date();
16 var PPQday=new Date(2010,9-1,28);
17 var DayTime = (PPQday.getTime()-Today.getTime())/ 1000 / 60 / 60 /24;
18 var days = parseInt(DayTime);//天
19 var HourTime =(DayTime - days)*24;
20 var hours =parseInt(HourTime);//时
21 var MinutesTime =(HourTime-hours)*60;
22 var minutes = parseInt(MinutesTime);//分
23 var SecondTime =(MinutesTime-minutes)*60;
24 var seconds = parseInt(SecondTime); //秒
25 var MillisecondTime = (SecondTime-seconds)*100;//取2位
26 var milliseconds = parseInt(MillisecondTime);//毫秒
27
28 document.getElementById("PPQTime").innerHTML= "距宝宝出生还有 "+ days + "天"+ ForMat(hours)+"小时"+ForMat(minutes)+"分"+ForMat(seconds)+"秒"+ForMat(milliseconds)+"毫秒";
29 setTimeout(Clock,100);
30
31
32 }
33 function ForMat(data)
34 {
35 if(data<10)
36 return "0"+data;
37 else
38 return data;
39 }
40 </script>
41 </head>
42 <body onload="Clock()">
43
44 <div id="PPQTime"></div>
45
46
47
48 </body>
49 </html>