Back Forward

Clocks


Updating Clock

This clock displays the time on the users machine:

It's done by putting this in between the <Head> tags of the document:

<SCRIPT LANGUAGE="JavaScript">

function TimeOutfunc() {
        timeout = window.setTimeout("TimeOutfunc()", 1000);
        var today = new Date();
        document.forms[0].elements[0].value = today.toString();
}


Then adding this to the body tag, like this:
<Body ONLOAD="timeout = setTimeout('TimeOutfunc();',1000);">
And finally adding this where you want the clock:
<FORM>
<INPUT TYPE="text" NAME="disp" VALUE="" SIZE="50">
</FORM>

Regular Clock

This script shows the time the viewer loaded the page:
Just put this wherever you want the clock to appear:

<SCRIPT language="JavaScript">
     <!-- Script Segment
     
             var now = new Date();
             var hours = now.getHours();
             var minutes = now.getMinutes();
             var seconds = now.getSeconds()
             var timeValue =""+((hours >12) ? hours -12 :hours)
             timeValue +=((minutes < 10) ? ":0" : ":")+minutes
             timeValue +=((seconds < 10) ? ":0":":")+seconds
             timeValue +=(hours >= 12) ? " P.M.":" A.M."
             document.write(timeValue);
     // End Script -->
     </SCRIPT>
That's it.

Date

Obviously, this script shows the date:

You just add this wherever you want the date to appear:

<SCRIPT>
     <!-- Start Script
     
             var text = "" 
             var now = new Date()
             var month = now.getMonth()
             var date = now.getDate()
             var year = now.getYear()
             now = null
             month++ // 0 - 11 => 1 - 12
             document.write(month + "/" + date + "/" + year);
     // End Script -->
     </SCRIPT>

1