0

getHours method and i get this error:

Uncaught TypeError: time0.getHours is not a function

here is my function :

function showtime(){
    var time0 = Date();
    var h = time0.getHours();
    var m = time0.getMinutes();
    var s = time0.getSeconds();
    
    if (h>12){
        h = h-12;
        var time01 =document.getElementById('clock').innerHTML=`Current time is : ${h}PM:${m}:${s}`;
        }
    else{
        var time01 =document.getElementById('clock').innerHTML=`Current time is : ${h}AM:${m}:${s}`;
    }
    var time = setTimeout(showtime,1000);
    return time;
}
showtime();

where is the mistake please ?

0 Answers0