'moment.js How to get the exact hour from seconds?

I have a timer in my project, I have time format in seconds 90000 I want to transform seconds in hours and minutes (HH:mm) using moment.js, I wonder how I can get the exact time, if time is less than 86399 moment works as expected, but my aim is to get such a result 25:00, is this possible with moment?

const secs = 90000;
const formatted = moment.utc(secs*1000).format('HH:mm');

document.write(formatted);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>


Solution 1:[1]

Try this

var seconds = 90000;
// multiply by 1000 because Date() requires miliseconds
var date = new Date(seconds * 1000);
var hh = date.getUTCHours();
var mm = date.getUTCMinutes();
var ss = date.getSeconds();
// If you were building a timestamp instead of a duration, you would uncomment the following line to get 12-hour (not 24) time
// if (hh > 12) {hh = hh % 12;}
// These lines ensure you have two-digits
if (hh < 10) {hh = "0"+hh;}
if (mm < 10) {mm = "0"+mm;}
if (ss < 10) {ss = "0"+ss;}
// This formats your string to HH:MM:SS
var t = hh+":"+mm+":"+ss;
document.write(t);
// result 1:00:00

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Henrique Kronhardt