小程序天/小时/分秒倒计时封装
Posted 好想再胖十斤
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小程序天/小时/分秒倒计时封装相关的知识,希望对你有一定的参考价值。
// 直接输出倒计时封装 function dayTime(bb) { var bb = bb var day = parseInt(bb/86400); var time = parseInt((bb-(day*86400))/3600); var min = parseInt((bb-(time*3600+day*86400))/60) var sinTime = time*3600+min*60+day*86400 var sinTimeb; var sin1 = parseInt((bb-sinTime)) var thisTime = addEge(day)+"天"+addEge(time)+":"+addEge(min)+":"+addEge(sin1); bb<=0?thisTime = "0天00:00:00":thisTime return thisTime } function addEge(a){ return a<10?a = "0"+a:a = a } // 输出数组倒计时封装 function dayTimeArr(bb) { var bb = bb var day = parseInt(bb/86400); var time = parseInt((bb-(day*86400))/3600); var min = parseInt((bb-(time*3600+day*86400))/60) var sinTime = time*3600+min*60+day*86400 var sinTimeb; var sin1 = parseInt((bb-sinTime)) var timeArr = [addEge(day),addEge(time),addEge(min),addEge(sin1)]; if(bb<=0){ timeArr = ["0","00","00","00"]; } return timeArr }
以上是关于小程序天/小时/分秒倒计时封装的主要内容,如果未能解决你的问题,请参考以下文章