Answers for "how to convert minutes into hours in javascript"

3

convert seconds to hours minutes seconds javascript

function secondsToHms(d) {
    d = Number(d);
    var h = Math.floor(d / 3600);
    var m = Math.floor(d % 3600 / 60);
    var s = Math.floor(d % 3600 % 60);

    var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : "";
    var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : "";
    var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : "";
    return hDisplay + mDisplay + sDisplay; 
}
Posted by: Guest on November-18-2020
1

javascript hours minutes seconds

var myDate = new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
    console.log(myDate)
//using regex
Posted by: Guest on May-09-2021

Code answers related to "how to convert minutes into hours in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language