JavaScript function for printing a countdown
Try this:

var time_format = (function() {

    var names = "yr mo w d h m s".split(" ");

    return function(time) {
        var elms, ret, i, n;
        elms = [
            time / 29030400,
            time / 2419200 % 12,
            time / 604800 % 4,
            time / 86400 % 7,
            time / 3600 % 24,
            time / 60 % 60,
            time % 60
        ];
        ret = [];
        for( i=0; i&lt;elms.length; i++) {
            n = elms[i];
            n = n | n;
            if( n) ret.push(n+names[i]);
        }
        ret = ret.join(" ");
        if( ret == "") ret = "0s";
        return ret;
    }
}());


It moves the array initialization out of the function and into a closure so it's only evaluated once.

And, it uses a faster way to do the floor operation.  See this article for different ways to do floor and their timing.