JSFiddle - React, Tailwind, and code Playground
by lollero
JavaScript
var sec = 60000;
var test = sec2time( sec );
console.log( sec2time( 60000 ) +' / '+ sec2time( 800000 ) );
function sec2time(timeInSeconds) {
var pad = function(num, size) { return ('000' + num).slice(size * -1); },
time = parseFloat(timeInSeconds).toFixed(3),
hours = Math.floor(time / 60 / 60),
minutes = Math.floor(time / 60) % 60,
seconds = Math.floor(time - minutes * 60),
milliseconds = time.slice(-3);
return (hours.toString().length > 1 ? hours : pad(hours, 2)) + 'h' + pad(minutes, 2) + 'm';
}