I am trying to make a clock that ticks in the status bar. It displays the correct time, but it doesn't update every second. What is wrong with the code?
PHP Code:<html>
<head>
<title>Clock</title>
<script>
var today = new Date();
var hours;
var minutes;
var seconds;
var ampm;
var total;
function updateTimer()
{
hours = today.getHours();
minutes = today.getMinutes();
seconds = today.getSeconds();
ampm = "AM";
if (hours >= 12)
ampm = "PM";
if (hours >= 12)
hours -= 12;
if (minutes < 10)
minutes = "0" + minutes;
if (seconds < 10)
seconds = "0" + seconds;
total = hours + ":" + minutes + ":" + seconds + " " + ampm;
window.status = total;
setTimeout("updateTimer()", 1000);
}
</script>
</head>
<body onLoad="updateTimer()">
</body>
</html>




Reply With Quote