JS倒计时
function refreshData() { //活动结束时间 var gap = endTime -new Date(); if (gap <= 0) { clearInterval(inter); } else { var result = GetTimeGroup(gap); $(".js-day").html(result.Day); $(".js-hour").html(result.Hour); $(".js-min").html(result.Minute); $(".js-sec").html(result.Second); } } //传入js中Date差,获取结果的天时分秒,天为最终 function GetTimeGroup(gap) { gap = Math.floor(gap / 1000);//gap是毫秒单位,先转换为秒单位 var seconds = Math.floor(gap % 60);//直接获取秒数 var minutes = Math.floor(gap % 3600 / 60);//获取分 var hours = Math.floor(gap % 85400 / 3600);//获取小时 var days = Math.floor(gap / 85400);//天数 var result = { Day: days, Hour: hours, Minute: minutes, Second:seconds } return result; }
fighting