Live Time on WP showing weirdly [closed]

Here’s an updated version of the code which fixes the extra zero caused by the redundant time checks in startTime():

JavaScript

function startTime() {
    var d=new Date();
    var h=d.getHours();
    var m=d.getMinutes();
    var s=d.getSeconds();
    h = h % 12;
    h = h ? h : 12; // the hour '0' should be '12'
    var ampm = h >= 12 ? 'PM' : 'AM';

    m = checkTime(m);
    s = checkTime(s);
    document.getElementById('timeis').innerHTML =" "+h+":"+m+":"+s;
}

function checkTime(i) {
    if ( i == 0 ) {
        return "00";
    }

    if ( i < 10 ) {
        i = "0" + i;
    }
    return i;
}

setInterval(function() {
    startTime();
}, 500);

HTML

<a id="timeis" href="#"></a>