Skip to content

Latest commit

 

History

History
14 lines (14 loc) · 478 Bytes

File metadata and controls

14 lines (14 loc) · 478 Bytes

Current Time in Readable format

function getCurrentTime() {
    var timeNow = new Date();
    var hours = timeNow.getHours();
    var minutes = timeNow.getMinutes();
    var seconds = timeNow.getSeconds();
    var timeString = "" + ((hours > 12) ? hours - 12 : hours);
    timeString += ((minutes < 10) ? ":0" : ":") + minutes;
    timeString += ((seconds < 10) ? ":0" : ":") + seconds;
    timeString += (hours >= 12) ? " P.M." : " A.M.";
    return timeString;
}