Am pm time html javascript
<script>
function startTime() {
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
var ampm = "";
m = checkTime(m);
s = checkTime(s);
if (h > 12) {
h = h - 12;
ampm = " PM";
} else if (h == 12){
h = 12;
ampm = " PM";
} else if (h < 12){
ampm = " AM";
} else {
ampm = "PM";
};
if(h==0) {
h=12;
}
document.getElementById('Time').innerHTML = h+":"+m+":"+s+ampm;
var t = setTimeout(function(){startTime()},500);
}
startTime();
function checkTime(i) {
if (i<10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
</script>
<body onload='startTime()'>
<div id='Time'></div> <!-- use some css with #Time -->
</body>
hacknasawithmatlab