jq倒计时
頁面里面的調用
Data為接口只需要獲得時間差即可var date1=new Date(data.display_begin_at); //開始時間var date2=new Date(data.display_end_at); //結束時間var date3=(date2.getTime()-date1.getTime())/1000; var time_stamp = date3;timer(time_stamp);頁面調用的中間函數function timeStamp(date) {return new Date(date).getTime();}倒計時的代碼function timer(intDiff) {window.setInterval(function(){var day=0,hour=0,minute=0,second=0;//時間默認值if(intDiff > 0){day = Math.floor(intDiff / (60 * 60 * 24));hour = Math.floor(intDiff / (60 * 60)) - (day * 24);minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);}if (minute <= 9) minute = '0' + minute;if (second <= 9) second = '0' + second;$('#day_show').html(day+'天');$('#hour_show').html(hour+'時');$('#minute_show').html(minute+'分');$('#second_show').html(second+'秒');intDiff --;}, 1000);}
?
轉載于:https://www.cnblogs.com/xinheng/p/9885106.html
總結
- 上一篇: gluPickMatrix和glRead
- 下一篇: 经典基础算法之面试题(系列一)(转)