var time_end = new Date(); // 设定结束时间
time_end = time_end.getTime()+7200000;//设置时间间隔为2小时
setTimeout("show_time()",1000);
function show_time() {
var time_start = new Date();//获得当前时间
time_start.getTime();
var time_distance = time_end-time_start;
var int_hour, int_minute, int_second;
if(time_distance>=0){
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;
// 显示时间
$("#time_h").text(int_hour);
$("#time_m").text(int_minute);
$("#time_s").text(int_second);
setTimeout("show_time()",1000);
}
}