var update_time = function(){
    var time = $('.time').data('time'),
        day,hour,minute,second,unit,
        rest_time = time - 1,
        num = 1,
        str ='';
    $('.temporary-time').data('time',rest_time);   
    day = Math.floor(rest_time/60/60/24);
    if(day){
        rest_time -= day*60*60*24;
    }
    hour = Math.floor(rest_time/60/60);
    if(hour){
        rest_time -= hour*60*60;
    }
    minute = Math.floor(rest_time/60);
    if(minute){
        rest_time -= minute*60;
    }
    second = rest_time;
    unit = {
        '天':day,
        '时':hour,
        '分':minute,
        '秒':second
    }
    for(var item in unit){
        str += unit[item]+item;
        num ++;
    }
    $('.temporary-time').text(str);
}
update_time();
setInterval(update_time,1000);

ranyuemelody
33 声望5 粉丝