倒計時函數
//倒计时函数 $scope.showtime=function(endTime){ var time_start = new Date().getTime(); //设定当前时间 var time_end = new Date(endTime).getTime(); //设定目标时间 // 计算时间差 var time_distance = time_end - time_start; if (time_distance > 0) { // 天 var int_day = Math.floor(time_distance / 86400000) time_distance -= int_day * 86400000; // 时 var int_hour = Math.floor(time_distance / 3600000) time_distance -= int_hour * 3600000; // 分 var int_minute = Math.floor(time_distance / 60000) time_distance -= int_minute * 60000; // 秒 var int_second = Math.floor(time_distance / 1000) $scope.countDown={ dayten:parseInt(int_day / 10), dayone:parseInt(int_day % 10), hourten:parseInt(int_hour / 10), hourone:parseInt(int_hour % 10), minuteten:parseInt(int_minute / 10), minuteone:parseInt(int_minute % 10), secondten:parseInt(int_second / 10), secondone:parseInt(int_second % 10) }; $timeout(function(){ $scope.showtime(endTime) }, 1000); } }
如下24小时倒计时
點擊查看更多內容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦