1 <DivID= "Times_wrap"class= "Time_num">2 distance End time:3 <Divclass= "Time_w">4 <bID= "Times_d"class= "Time"> </b>days5 <bID= "Times_h"class= "Time"> </b>when6 <bID= "Times_m"class= "Time"> </b>points7 <bID= "times_s"class= "Time"> </b>seconds8 </Div>9 </Div>
1 varTime_wrap = document.getElementById ("Times_wrap");2 varTime_d = document.getElementById ("Times_d");3 varTime_h = document.getElementById ("Times_h");4 varTime_m = document.getElementById ("Times_m");5 vartime_s = document.getElementById ("times_s");6 7 varTime_end =NewDate ("2015/9/30 18:00:00");//Set End Time8Time_end =time_end.gettime ();9 Ten functionShow_time () { One varTime_now =NewDate ();//Get current Time ATime_now =time_now.gettime (); - varTime_distance = Time_end-time_now;//end time minus current time - varInt_day, Int_hour, Int_minute, Int_second; the if(time_distance >= 0){ - //Day and seconds conversion -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) ATime_distance-= Int_minute * 60000; atInt_second = Math.floor (time_distance/1000) - - //Time division seconds is singular, front plus 0 stance - if(Int_hour < 10) -Int_hour = "0" +Int_hour; - if(Int_minute < 10) inInt_minute = "0" +Int_minute; - if(Int_second < 10) toInt_second = "0" +Int_second; + - //Show Time thetime_d.innerhtml =Int_day; *time_h.innerhtml =Int_hour; $time_m.innerhtml =Int_minute;Panax Notoginsengtime_s.innerhtml =Int_second; -}Else{ thetime_d.innerhtml =time_d.innerhtml; +time_h.innerhtml =time_h.innerhtml; Atime_m.innerhtml =time_m.innerhtml; thetime_s.innerhtml =time_s.innerhtml; + } - }; $Window.setinterval (function(){ $ show_time (); -}, 1000);
JS countdown (can be defined due date)