1.js设置倒计时日期
//data 格式MM-dd-yyyy HH:mm:ss
function ShowTime(data){
window.setTimeout(function(){this.ShowTime(time);}, 1000);
var serverDay=new Date(data);
var today=New Date();
var s_t_time=serverDay.getTime()-today.getTime();
var ss_time=Math.floor(s_t_time/1000);
var day_time=s_t_time/(24*60*60*1000);
var day=Math.floor(day_time);
var hours_time=(day_time-day)*24;
var hh=Math.floor(hours_time);
var min_time=(hours_time-hh)*60;
var mm=Math.floor((hours_time-hh)*60);
var ss=Math.floor((min_time-mm)*60);
if(day<=0){
document.write("时间到!哈哈");
}
else{
document.write(day+"天"+hh+"小时"+mm+"分"+ss+"秒");
}
}
ShowTime("1-10-2012 22:06:45");