Copy codeThe Code is as follows: <! 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>
<Title> </title>
<Script src = "http://img.jb51.net/jslib/jquery/jquery-1.7.1.min.js" type = "text/javascript"> </script>
<Script type = "text/javascript">
Function showTime (tuanid, time_distance ){
This. tuanid = tuanid;
// PHP time is second, JS time is microsecond
This. time_distance = maid * 1000;
}
ShowTime. prototype. setTimeShow = function (){
Var timer = $ ("# lefttime _" + this. tuanid );
Var str_time;
Var int_day, int_hour, int_minute, int_second;
Time_distance = this. time_distance;
This. time_distance = this. time_distance-1000;
If (time_distance> 0 ){
Int_day = Math. floor (time_distance/86400000 );
Time_distance-= int_day * 86400000;
Int_hour = Math. floor (time_distance/3600000 );
Time_distance-= int_hour* 3600000;
Int_minute = Math. floor (time_distance/60000 );
Time_distance-= int_minute * 60000;
Int_second = Math. floor (time_distance/1000 );
If (int_hour <10)
Int_hour = "0" + int_hour;
If (int_minute <10)
Int_minute = "0" + int_minute;
If (int_second <10)
Int_second = "0" + int_second;
Str_time = int_day + "day" + int_hour + "Hour" + int_minute + "Minute" + int_second + "second ";
Timer. text (str_time );
Var self = this;
SetTimeout (function () {self. setTimeShow () ;}, 1000); // D: Correct
} Else {
Timer. text ("End of group buying ");
Return;
}
}
</Script>
</Head>
<Body>
<Div id = "lefttime_1" time = "2011/11/23 6:58:23">
</Div>
<Script type = "text/javascript">
Var st = new showTime (1, 3 );
// St. tuanid = 1;
// St. time_distance = 10000;
St. setTimeShow ();
</Script>
<Div id = "lefttime_2" time = "2011/11/24 6:58:23">
</Div>
<Script type = "text/javascript">
Var st = new showTime (2, 5 );
// St. tuanid = 1;
// St. time_distance = 10000;
St. setTimeShow ();
</Script>
</Body>
</Html>
Jquery is required for the above Code.