If you know the number of seconds you have, this will work. It also uses the native Date() object.
function formattime(numberofseconds){ var zero = '0', hours, minutes, seconds, time; time = new Date(0, 0, 0, 0, 0, numberofseconds, 0); hh = time.getHours(); mm = time.getMinutes(); ss = time.getSeconds() // Pad zero values to 00 hh = (zero+hh).slice(-2); mm = (zero+mm).slice(-2); ss = (zero+ss).slice(-2); time = hh +':'+ mm +':'+ ss; return time; }