奧運倒計時<span id="timeDate">載入天數...</span><span id="times">載入倒計時秒...</span>6 s6 y( Z# k+ @
<script>1 K& n7 n$ Y7 i1 O
var now = new Date();
6 H# d* ]6 s; ]/ y8 \4 N. d3 l0 sfunction createtime(){
0 E. q8 u( M, J- G' o. n6 h7 O" v9 M, w) s3 h4 w- I% P
var grt= new Date("8/08/2008 20:00:00");
" d4 U! K! o0 C' M: I9 `$ T+ B) p
& I# Q( ^6 a5 h% P2 y8 y/ j4 Xnow.setTime(now.getTime()+250);7 a4 [* o! f2 T# b; @8 n6 n
days = (grt - now) / 1000 / 60 / 60 / 24;
0 o$ [8 X$ F& Q f& r& X. r7 f: ^dnum = Math.floor(days);
% R1 q1 l% W! s" o1 [. Lhours = (grt - now) / 1000 / 60 / 60 - (24 * dnum);
! |* ~ }% X, G& h3 P7 z. ~hnum = Math.floor(hours);4 u4 u! {+ J: m ~8 H0 t
if(String(hnum).length ==1 ){hnum = "0" + hnum;}
1 f' p2 X' U) V" P+ S6 y+ a# p: bminutes = (grt - now) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);. @' [2 N9 k' l$ u1 H
mnum = Math.floor(minutes);( M; w$ d( n) D& Y0 F( f4 v9 r1 T
if(String(mnum).length ==1 ){mnum = "0" + mnum;}" ^0 _! m. W4 A6 f9 O8 f% L* i
seconds = (grt - now) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
Z( o4 a9 m0 e1 j6 Y. isnum = Math.round(seconds);
- L( o E0 b* O& l E7 fif(String(snum).length ==1 ){snum = "0" + snum;}
) c9 K9 N$ e' ^* |; H/ B( @0 K+ {% v0 f6 d
document.getElementById("timeDate").innerHTML = dnum+"天"; X# b1 O/ Q6 N, c g8 W/ |3 o
document.getElementById("times").innerHTML = hnum + ":" + mnum + ":" + snum;
* k: W9 J/ S/ v}
: k' C( u8 H5 ]' z3 t! U* E/ `* a% P6 V4 D7 R& P$ F
setInterval("createtime()",250); 5 m# I" T2 n1 r5 @, t& k
</script>
. a& A: |6 e8 } Y
( E. s6 \9 H! O P& {6 Q0 J
& h6 Q0 |' Y$ y" [- n' L- ] @
9 p% W! V, H' ^% f( ^- x演示:http://www.zzwang.com/ |
|