HTML Source box #1 - SYDNEY.HTM
<HTML>
<HEAD>
<TITLE>Javascript Clock</TITLE>
<SCRIPT LANGUAGE = "Javascript">
<!--
//the function to get the time data
function setTime() {
//initialise variables
//Adjust the localGMT figure for your local time zone...
//Brisbane, Sydney & Melbourne +10 hours
//Perth +8 hours
//Adelaide, Darwin +9.5 hours
//remember to add an additional hour in summer to
//account for Daylight Saving if your state has it.
myLocalGMT = 10;
//new date object for your visitors time
currentTime = new Date();
//the difference between your visitors time and GMT in minutes
timeDifference = currentTime.getTimezoneOffset();
//adjust visitor's time to your local standard time
currentTime.setMinutes(currentTime.getMinutes() - timeDifference +
myLocalGMT * 60);
var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes();
//assume it is the afternoon
var currentAmPm = "pm"
//adjust for a 24 hour clock
if (currentHours > 12)
currentHours = currentHours - 12;
else {
//set 'am' for hours 0 - 11 inclusive
if (currentHours <= 11)
currentAmPm =
"am";
//adjust for midnight
if (currentHours == 0)
currentHours =
currentHours + 12;
}
//pad hours to two digits
if (currentHours <= 9)
currentHours
= " " + currentHours
//pad minutes to two digits
if (currentMinutes <= 9)
currentMinutes = "0" + currentMinutes
//build a string for the time
currentTime = currentHours + ":" + currentMinutes +
currentAmPm;
//display this string in the text box on the form
document.displayClock.time.value = currentTime
//call this function again in 10 seconds time
setTimeout ("setTime()", 10000)
}
//-->
</SCRIPT>
</HEAD>
<BODY OnLoad = "setTime()" BGCOLOR="#004080"
TEXT="#FFEEEE">
<FONT FACE = 'arial'><H1>Javascript Clock</H1>
This is a simple Javascript clock which<br>
reads the system clock and updates it<br>
at 10 second intervals.<P>
<!-- The clock is displayed in a text input box on a form -->
<FORM NAME = "displayClock">
<H1>
Time in Sydney: <INPUT TYPE = "text" NAME = "time" SIZE= 6>
</H1></FORM>
</BODY>
</HTML>: |
|
|