1. 程式人生 > >小程序天/小時/分秒倒計時封裝

小程序天/小時/分秒倒計時封裝

asc 封裝 hist -s int this 數組 highlight b-s

// 直接輸出倒計時封裝
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
}

  

小程序天/小時/分秒倒計時封裝