倒计时方法

servertiem 现在时间 datatime 目标时间

        function timeCount(servertime,datatime,obj){            
            if(datatime
获取时间差函数并转换为:天时分秒
     function interval(timedifference,datatime){
        var timecount = parseInt(datatime) + timedifference - new Date();
        if(timecount<=0)return false;
        var int_day, int_hour, int_minute, int_second;
        int_day = Math.floor(timecount/86400000);
        int_hour = Math.floor(timecount%86400000/3600000);
        int_minute = Math.floor(timecount%3600000/60000);
        int_second = Math.floor(timecount%60000/1000);
            int_hour = int_day*24+int_hour;
            if(int_hour < 10)
            int_hour = "0" + int_hour;
            if(int_minute < 10)
            int_minute = "0" + int_minute;
            if(int_second < 10)
            int_second = "0" + int_second;
            var result = ""+int_hour+int_minute+int_second;
         //一定要加空字符串,否则是数字相加而不是拼接了
            return result;
     }

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