I'm trying to fetch the duration of each mp3 sound but sometimes it displays the duration while other times it shows invalid.
I want to print the time in hh:mm:ss format.
Div Block where i'm showing duration:
var duration17 = document.getElementById("audio-17").duration;
        duration17 = secondstotime(duration17);
        document.getElementById("duration-17").innerHTML = duration17;
My function for converting seconds to proper time:
//convert seconds to the proper time duration
    function secondstotime(secs)
    {
        var t = new Date(1970,0,1);
        t.setSeconds(secs);
        var s = t.toTimeString().substr(0,8);
        if(secs > 86399)
            s = Math.floor((t - Date.parse("1/1/70")) / 3600000) + s.substr(2);
        return s;
    }
 
     
     
    