| <SCRIPT>
// create a Time
Variable then get the hours, minutes, & seconds
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
// am or pm?
var ampm = "am";
// assign an
HTML string to the variable colon, this makes it easier to read code
later on
var colon = '<IMG SRC="images/colon.gif">';
// since hours go
from 0 - 23 the hours need to be converted
if (hours >= 12) {
ampm = "pm";
hours = hours - 12;
}
// if hour = 0
then convert to 12,
// NOTE: also takes care of the above situation where hours =
hours - 12
if (hours == 0) hours = 12;
// if less then 10
we need the "0" placeholder for hours
if (hours < 10) hours = "0" + hours;
else hours = hours + '';
// if less then 10
we need the "0" placeholder for minutes
if (minutes < 10) minutes = "0" + minutes;
else minutes = minutes + '';
// if less then 10
we need the "0" placeholder for seconds
if (seconds < 10) seconds = "0" + seconds;
else seconds = seconds + '';
// once we have
the time parts we can then physically write out the time using gifs
document.write('<IMG
SRC="images/' + hours.charAt(0)
+ '.gif">');
document.write('<IMG
SRC="images/' + hours.charAt(1)
+ '.gif">');
document.write(colon);
document.write('<IMG
SRC="images/' + minutes.charAt(0)
+ '.gif">');
document.write('<IMG
SRC="images/' + minutes.charAt(1)
+ '.gif">');
document.write(colon);
document.write('<IMG
SRC="images/' + seconds.charAt(0)
+ '.gif">');
document.write('<IMG
SRC="images/' + seconds.charAt(1)
+'.gif">');
document.write('<IMG
SRC="images/' + ampm + '.gif">');
</SCRIPT> |