~function(){ const nextPushTime = $('#nextPushTime_promotion_push'); const prevTime = new Date('2017-11-12 16:53:00').getTime() + 2*24*60*60*1000; const nowTime = new Date().getTime(); let seconds = prevTime - nowTime; //倒计时的秒数 let timer = setInterval(function (){ num = seconds/1000; let text = '距离下次推送时间为:' + (Math.floor(num/86400) < 10 ? '0' + Math.floor(num/86400) :Math.floor(num/86400)) + '天' + (Math.floor(num%86400/3600) < 10 ? '0' + Math.floor(num%86400/3600):Math.floor(num%86400/3600)) + '小时' + (Math.floor(num%3600/60) < 10 ? '0' + Math.floor(num%3600/60):Math.floor(num%3600/60))+ '分' + ((num%60).toFixed(0) < 10 ? '0' + (num%60).toFixed(0): (num%60).toFixed(0)) + '秒'; if(num < 1000) { text = '您现在可发送促销推送'; clearInterval(timer); } nextPushTime.text(text); seconds = seconds -1000; }, 1000) }();