World Time
Created | Updated Oct 20, 2010
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var timerRunning = false;
var timezone = "Greenwich Mean Time"; // what time zone are you in ?
var adjust = 0;
function timeCheck(tzone, diff) {
if (timerRunning) {
clearTimeout(updatetime);
timerRunning = false; }
gmtOffset=eval(diff+adjust);
timezone = tzone;
checkDateTime();
}
function checkDateTime () {
var today = new Date();
var year = today.getYear() + 1900;
var month = today.getMonth()+1;
var date = today.getDate();
var day = today.getDay();
var hour = today.getHours();
var minute = today.getMinutes();
var second = today.getSeconds();
var lastSat = date - (day+1);
while (lastSat < 32) lastSat+=7;
if (lastSat > 31) lastSat+=-7;
var firstSat = date - (day+1);
while (firstSat > 0) firstSat+=-7;
if (firstSat < 1) firstSat+=7;
if ((((month == 4) && (date >= firstSat)) || month > 4) &&
(month < 11 || ((month == 10) && day <= lastSat))) adjust += 60;
yourOffset = (new Date()).getTimezoneOffset();
yourOffset = yourOffset + adjust;
var xx = navigator.appName
var xy = navigator.appVersion;
xy = xy.substring(0,1);
if ((xy == 4) && (xx == "Netscape")) yourOffset = yourOffset+adjust;
if ((((month == 4) && (date > 20)) || month > 4) && (month < 11 || ((month == 10) &&
day < 30))) adjust -= 60;
ourDifference = eval(gmtOffset - yourOffset);
var half = eval(ourDifference % 60);
ourDifference = Math.round(ourDifference / 60);
hour = eval(hour - ourDifference);
var m = new Array("",
"Jan","Feb","Mar",
"Apr","May","Jun",
"Jul","Aug","Sept",
"Oct","Nov","Dec");
var leap = eval(year % 4);
if ((half == -30) || (half == 30)) minute += 30;
if (minute > 59) minute -= 60, hour++;
if (minute < 0) minute += 60, hour--;
if (hour > 23) hour -= 24, date += 1;
if (((month == 4) || (month == 6) ||
(month == 9) || (month == 11)) && (date==31)) date = 1, month ++;
if (((month == 2) && (date > 28)) && (leap != 0)) date = 1, month ++;
if ((month == 2) && (date > 29)) date = 1, month++;
if (hour < 0) hour += 24, date --;
if ((date == 32) && (month == 12)) month = m[1], date = 1, year++;
if (date == 32) date = 1, month++;
if ((date < 1) && (month == 1)) month= m[12], date = 31, year--;
if (date < 1) date = 31, month --;
if (((month == 4) || (month == 6) ||
(month== 9) || (month == 11)) && (date == 31)) date = 30;
if ((month == 2) && (date > 28)) date = 29;
if (((month == 2) && (date > 28)) && (leap != 0)) date=28;
for (i=1; i<13; i++) {
if (month == i) {
month = m[i]; break;
}
}
var dateTime = hour;
dateTime = ((dateTime < 10) ? "0":"") + dateTime;
dateTime = " " + dateTime;
dateTime += ((minute < 10) ? ":0" : ":") + minute;
dateTime += ((second < 10) ? ":0" : ":") + second;
dateTime += (hour >= 12) ? " PM, " : " AM, ";
dateTime += month + " " + date + ", " + year;
document.clock.zonetime.value = dateTime;
document.clock.zonename.value = timezone;
updatetime=setTimeout("checkDateTime()", 900);
timerRunning = true;
}
// End -->
</SCRIPT>
</HEAD>
<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->
<BODY OnLoad="timeCheck(timezone, 0)">
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<center>
<h2>World Clock</h2>
<form name=clock>
<input type=text name=zonetime size=31><BR/>
<BR/>
<b>Current Time Zone</b><BR/>
<input type=text name=zonename size=21>
<BR/>
<BR/>
<table border=1 cellpadding=5>
<tr>
<td align=center><input type=button value="Australia" onClick="timeCheck(this.value, +920)"></td>
<td align=center><input type=button value="Central" onClick="timeCheck(this.value, +420)"></td>
<td align=center><input type=button value="Eastern" onClick="timeCheck(this.value, +300)"></td>
</tr>
<tr>
<td align=center><input type=button value="Hawaii" onClick="timeCheck(this.value, +600)"></td>
<td align=center><input type=button value="Mexico" onClick="timeCheck(this.value, +360)"></td>
<td align=center><input type=button value="New Delhi" onClick="timeCheck(this.value, -330)"></td>
</tr>
<tr>
<td align=center><input type=button value="Hong Kong" onClick="timeCheck(this.value, -480)"></td>
<td align=center><input type=button value="Tokyo" onClick="timeCheck(this.value, -540)"></td>
<td align=center><input type=button value="London" onClick="timeCheck(this.value, +0)"></td>
</tr>
</table>
</form>
</center>
<P>Please Beware this page is still being created and any time you come across may not be exactly right!
<BR/>