奧運倒計時<span id="timeDate">載入天數...</span><span id="times">載入倒計時秒...</span>
$ U( A% y+ O8 g, X& R l9 e5 a<script>
2 Z. K* J8 Z- I( ]0 J" ]9 _var now = new Date();
/ Y: Y3 q. ^% x% n+ D( U: ]0 Bfunction createtime(){* y, b* m) G+ d i7 L
) D8 v3 v. R3 P( F
var grt= new Date("8/08/2008 20:00:00");
/ }2 ~- h5 v* ~
2 N" g; F: f& D5 K9 \now.setTime(now.getTime()+250);. h/ e$ A8 Z) S! n4 E( u
days = (grt - now) / 1000 / 60 / 60 / 24;: U! x, L" F8 a" ? I5 {
dnum = Math.floor(days);# o; T C$ x* S2 `1 X6 a
hours = (grt - now) / 1000 / 60 / 60 - (24 * dnum);+ a7 @. B; B& x' f2 N
hnum = Math.floor(hours);- D: M0 t! I3 c( g+ k
if(String(hnum).length ==1 ){hnum = "0" + hnum;}
% w+ _7 g$ s6 @minutes = (grt - now) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);6 |" t: x/ b, h8 `5 U: [
mnum = Math.floor(minutes);2 t/ m' H4 R# E; a( t) \0 i9 K
if(String(mnum).length ==1 ){mnum = "0" + mnum;}
% }3 W1 s& B G- P. _( O# q! cseconds = (grt - now) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
+ `% w! t. O3 ^+ e7 \5 Rsnum = Math.round(seconds);
0 g) S* G2 A, fif(String(snum).length ==1 ){snum = "0" + snum;}
, Z- v2 D% z! L" u Z5 i$ t* I! ~. k, T' r* \/ t8 g$ x5 K
document.getElementById("timeDate").innerHTML = dnum+"天";3 o! `5 o" k; v* M* T+ I7 B
document.getElementById("times").innerHTML = hnum + ":" + mnum + ":" + snum; y: i: y5 o' s- a- G
}
1 `0 c$ e5 o9 b) V+ ^, b2 t, ]' m( S4 B2 L" G
setInterval("createtime()",250);
/ B$ ]7 N0 J2 \+ l4 {& w8 y</script>
2 s9 j# d* x) j t+ [! m
9 q7 G% |: d& Q( \% a9 ]* Y; X+ A/ W2 k) C
4 R! |5 C; b' Y3 h. x! d8 }7 N. w演示:http://www.zzwang.com/ |
|