小程序天/小时/分秒倒计时封装

// 直接输出倒计时封装
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
}

  

posted @ 2017-11-15 16:21  好想再胖十斤  阅读(1572)  评论(0编辑  收藏  举报