Status Bar Digital Clock

Submitted by:Tim Kelly

Date added:22 November, 2011

Category:JavaScript

Check out the Time in the Status Line at the bottom left.

Tags: digital clock

Code Snippet:

<SCRIPT>

function showTime() {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();

var timeStr = "" + ((hours > 12) ? hours - 12 : hours);

timeStr += ((minutes < 10) ? ":0" : ":") + minutes;
timeStr += ((seconds < 10) ? ":0" : ":") + seconds;
timeStr += (hours >= 12) ? " P.M." : " A.M.";

status = timeStr; // time is displayed in the Status Line

setTimeout("showTime()", 1000);
}

</SCRIPT>

<BODY onLoad="showTime()">
 
 

Comments