JSFiddle - React, Tailwind, and code Playground

HTML

<div id="oset">

</div>

JavaScript

var timeofday = new Date().getHours() + (new Date().getMinutes()) / 60;
   console.log(typeof(timeofday))




 function timeD2C(time) { // Converts 11.5 (decimal) to 11:30 (colon)
    var pos = time.indexOf('.');
    var hrs = time.substr(1, pos - 1);
    var min = (time.substr(pos, 2)) * 60;

    if (hrs > 11) {
        hrs = (hrs - 12) + ":" + min + " PM";
    } else {
        hrs += ":" + min + " AM";
    }
    return hrs;
}
 document.getElementById("oset").innerHTML = timeD2C(""+timeofday);