1.用jquery实现时间计时器,从之前的某个时间段到现在距离多少天多少时多少分多少秒? html代码: 复制代码 代码如下: 距离现在时间: 天 时 分 秒 <BR>$(function(){ <br><br>show_time(); <br><br>}); <br><br>function show_time(){ <BR>var time_start = new Date("2013/10/01 00:00:00").getTime();//设定开始时间 <BR>var time_end = new Date().getTime(); //设定结束时间(等于系统当前时间) <BR>//计算时间差 <BR>var time_distance = time_end - time_start; <BR>if(time_distance > 0){ <BR>// 天时分秒换算 <BR>var int_day = Math.floor(time_distance/86400000) <BR>time_distance -= int_day * 86400000; <br><br>var int_hour = Math.floor(time_distance/3600000) <BR>time_distance -= int_hour * 3600000; <br><br>var int_minute = Math.floor(time_distance/60000) <BR>time_distance -= int_minute * 60000; <br><br>var int_second = Math.floor(time_distance/1000) <BR>// 时分秒为单数时、前面加零 <BR>if(int_day < 10){ <BR>int_day = "0" + int_day; <BR>} <BR>if(int_hour < 10){ <BR>int_hour = "0" + int_hour; <BR>} <BR>if(int_minute < 10){ <BR>int_minute = "0" + int_minute; <BR>} <BR>if(int_second < 10){ <BR>int_second = "0" + int_second; <BR>} <BR>// 显示时间 <BR>$("#time_d").html(int_day); <BR>$("#time_h").html(int_hour); <BR>$("#time_m").html(int_minute); <BR>$("#time_s").html(int_second); <br><br>setTimeout("show_time()",1000); <br><br>}else{ <BR>$("#time_d").html('00'); <BR>$("#time_h").html('00'); <BR>$("#time_m").html('00'); <BR>$("#time_s").html('00'); <br><br>} <BR>} <BR>