function fixNumber(number) { if (number >= 0 && number < 10) return `0${number}` return number; } function minuteToHour(minute) { let hour = Math.floor(minute / 60); minute = minute - hour * 60; return `${fixNumber(hour)}:${fixNumber(minute)}`; } console.log(minuteToHour(120)) // for test
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter