Home
About
Specials
Web Design
Used Items
Tech
Links
Contact
Guestbook
Fort Myers
Hobbies

 

This site enhanced for

This WCCS Web Site is Optimized for the Internet Explorer Current Version
Tips Clock

Current Time

Today's Date

A nifty JavaScript real-time clock (which gets the time from your computer's clock, by the way), and a real-time "Date" field.  You can see the example above... 

Here's how to do it:

Step One: enter the following JavaScript code Between Header Tags for your page:

<script language = "JavaScript">
<!-- Hide JavaScript from non-JS aware browsers

// This function sets up the clock
function StartClock12(); {
Time12 = new Date();
Cur12Hour = Time12.getHours();
Cur12Mins = Time12.getMinutes();
Cur12Secs = Time12.getSeconds();
The12Time = (Cur12Hour > 12) ? Cur12Hour - 12 : Cur12Hour;
The12Time += ((Cur12Mins < 10) ? ':0' : ':') + Cur12Mins;
The12Time += ((Cur12Secs < 10) ? ':0' : ':') + Cur12Secs;
document.CForm.Clock12.value = The12Time;
setTimeout('StartClock12()',1000);
}

// This function sets up the Date display
function StartDate(); {
TDay = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); // from Tday to here is one line
TMonth = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'Sepember', 'October', 'November', 'December'); // from 'Tmonth' to here is one line
TDate = new Date();
CurYear = TDate.getYear();
CurMonth = TDate.getMonth();
CurDayOw = TDate.getDay();
CurDay = TDate.getDate();
TheDate = TDay[CurDayOw] + ', ';
TheDate += TMonth[CurMonth] + ' ';
TheDate += CurDay + ', ';
TheDate += (CurYear + 1900);
// Please note that you'll need to change '1900' to '2000'
// after Dec 31, 1999... :)
document.CForm.CDate.value = TheDate;
}

// Done hiding -->
</script>

Step Two: Enter the following code into the Body of your page:

onLoad = "StartClock12();StartDate()"

Step Three: Define the Layout Area you wish to have the clock displayed in as a Form and name this form "CForm"

Step Four: Add a single-line Form Entry Field to this layout area. Name it "Clock12" and set it's visible length to 12. This will be where the time is displayed.

Step 5: Add another single-line Form Entry field to the layout region and name it "CDate". Set the visible length to 25. This will be where the date is displayed as "Day of Week, Day, Month Year"

You are here: Home > Web Design > Web Tips > Tips Clock

All Prices mention on this web site are Subject to Change at any time.
All Pages are design and copyright Ó 1999,2000,2001 David Ward