倒计时

html

距离下一场竞猜
25
:
35
:
25

倒计时 23:59:59

//countDown($(".time_box.one"),"2018-06-12 00:00:00");
function countDown(div, date) {
    var times = formIos(date).getTime() / 1000 - new Date().getTime() / 1000;
    var timer = null;
    timer = setInterval(function () {
        var hour = 0,
            minute = 0,
            second = 0;//时间默认值
        if (times > 0) {
            hour = Math.floor(times / (60 * 60));
            minute = Math.floor(times / 60) - (hour * 60);
            second = Math.floor(times) - (hour * 60 * 60) - (minute * 60);
        }
        if (hour <= 9) hour = '0' + hour;
        if (minute <= 9) minute = '0' + minute;
        if (second <= 9) second = '0' + second;
        div.find("div").eq(0).text(hour);
        div.find("div").eq(1).text(minute);
        div.find("div").eq(2).text(second);
        times--;
    }, 1000);
    if (times <= 0) {
        clearInterval(timer);
    }
}

你可能感兴趣的:(倒计时)