Convert seconds to HH-MM-SS format in JavaScript
In this tutorial, let’s see how to convert seconds to Hours Minutes Seconds (HH-MM-SS) format in JavaScript.
An easy way is to create a date will null value, set seconds to it, read date as string.
Advertisements
let timeInSecs = 5000; let date= new Date(null); date.setSeconds(timeInSecs); let hhmmsstime = date.toISOString().substr(11, 8); console.log(hhmmsstime); //01:23:20