Convert seconds to hours in ExtJS

0

I want to convert seconds to hours in ExtJS and would like to know if there is a function similar to gmdate ("H: i: s", $ total) in PHP.     

asked by anonymous 07.04.2014 / 19:56

1 answer

1

You can do a function in javascript. Something like:

function segundosParaHora(seg) {
        var horas = Math.floor(seg/(60*60));

        var resto = seg % (60*60);
        var minutos = Math.floor(seg/60);

        resto %= 60;
        segundos = Math.ceil(resto);

        var hora = {
            "H": horas,
            "i": minutos,
            "s": segundos
        };
        return hora;
}

I used 60 * 60 for readability (60s in 1min and 60min in 1 hour), but you can put the 3600 with no problem.

    
07.04.2014 / 20:39