<div class="time timers" rel="<?php echo date(‘m/d/Y‘, time()+24*3600)?>">
<span class="ico_time"></span>
<span class="data_title ">还剩
<span
class="data_pink pinkft"><span
class="hours">7</span>时<span
class="mins">46</span>分<span
class="">33</span>秒</span>
</span>
</span>
</div>
//以下是js代码
$(document).ready(function(){
timing();
});
// 倒计时
function timing()
{
$(".timers").each(function(){
var endtime = new Date($(this).attr("rel")).getTime();
var nowtime = new Date();
var youtime = 0;
youtime = endtime - nowtime;
var seconds = youtime/1000;
var minutes = Math.floor(seconds/60);
var hours = Math.floor(minutes/60);
var CHour= hours % 24;
var CMinute= minutes % 60;
var CSecond= Math.floor(seconds%60);//"%"
var MS=Math.floor(youtime) % 10;
if(endtime<=nowtime){
//$(this).html("已过期")//如果结束日期小于当前日期就提示过期啦
}else{
$(this).html("还剩<span class=‘pinkft data_pink‘><span
class=‘hours‘>"+CHour+"</span>时<span
class=‘mins‘>"+CMinute+"</span>分<span
class=‘‘>"+CSecond+‘.‘+MS+"</span>秒</span>");
if(CHour < 10){
$("#hours").text("0"+CHour);
}else{
$("#hours").text(CHour);
}
if(CMinute < 10){
$("#minute").text("0"+CMinute);
}else{
$("#minute").text(CMinute);
}
if(CSecond < 10){
$("#second").text(CSecond+‘.‘+MS);
}else{
$("#second").text(CSecond+‘.‘+MS);
}
}
});
setTimeout("timing()",100);
}