JS部分
复制代码代码如下:
setInterval( "time_controller()"、1000);
function time_controller(){
$( "。time_val")。各(function(){
var time_id = "time_show _"+$(this).attr( 'for');
var time_val = $(this).attr( 'value');
$(this).attr( 'value'、time_val-1);
show_time(time_id、time_val*1000);
});
}
関数show_time(id、タイムスタンプ)
{
var timer = document.getElementById(id);
var str_time、int_day、int_hour、int_minute、int_second;
var time_distance = timestamp;
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 = "<b>剩余时间:"+int_day+"天"+int_hour+"小时"+int_minute+"分钟"+int_second+"秒</b>";
Timer.innerhtml = str_time;
}それ以外{
Timer.innerhtml = "<b>剩余时间:0天0小时0分钟0秒</b>";
}
}
html部分、php和js的时间倒计时
复制代码代码如下:
<div id = "time_show _ {$ list.cmd_id}"> </div>
<入力型= "hidden" for = "{$ list.cmd_id}" value = "{$ list.time_val}" />