倒计时
//计算天、时、分
var end_date = new Date("2017/03/05 00:00:00").getTime();//IE Safari 不支持 2017-03-05 00:00:00 且 不支持 2017 -03 -05 24:00:00
function SetRemainTime() {
var now_date = new Date().getTime();
var diff_date = end_date - now_date;
var diff_time = parseInt(diff_date / 1000) + 60;//精确到秒 增加一分钟
if (diff_time > 0) {
var day = Math.floor(diff_time / 60 / 60 / 24);
var hour = Math.floor((diff_time - day * 24 * 60 * 60) / 60 / 60);
var minite = Math.floor((diff_time - day * 24 * 60 * 60 - hour * 60 * 60) / 60);
if (day < 10) {
day = '0'+day;
}
if (hour < 10) {
hour = '0'+hour;
}
if (minite < 10) {
minite = '0'+minite;
}
$("#t_d").html(day);
$("#t_h").html(hour);
$('#t_m').html(minite);
} else {
window.clearInterval(InterValObj);
}
}
$(function() {
InterValObj = window.setInterval(SetRemainTime, 1000); //间隔函数,1秒执行
});