This is a Html and Javascript current time display code, I am trying to add AM:PM
for this, but it does not display I am used for var ampm = toda.getampm();
how to display correctly this format
example
9 : 59 : 42 AM
function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
// add a zero in front of numbers<10
m = checkTime(m);
s = checkTime(s);
document.getElementById('time').innerHTML = h + " : " + m + " : " + s ;
t = setTimeout(function() {
startTime()
}, 500);
}
startTime();
<div id="time"></div>