Menu
Im looking for a script that gets the GMT so I can display times around the world on my website.
All the scripts I see get the computers time, which if you are in different time zones displays the wrong times…
Anyone have anything like this?
This one is cool but if you change your computer clock to your region, all the times are wrong!
[url]http://www.pacom.mil/staff/at/athome.shtml
Thanks!
[code=html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Time Zones</title>
<script type="text/javascript">
<!--//
var z = new Array();
var zones = new Array(
"Greenwich Mean Time",
"Azores Time",
"Mid-Atlantic Time",
"Newfoundland Time",
"Atlantic Standard Time",
"Eastern Standard Time",
"Central Standard Time",
"Mountain Standard Time",
"Pacific Standard Time",
"Alaska Standard Time",
"Hawaii Standard Time"
); // no comma after last entry above
function timeZone(ofs) {
var curDate = new Date();
var ss = curDate.getUTCSeconds();
ss = (ss<10)?"0"+ss:ss;
var mm = curDate.getUTCMinutes();
mm = (mm<10)?"0"+mm:mm;
var hh = curDate.getUTCHours();
hh -= ofs;
hh = (hh<0)?hh+24:hh;
ss += (hh > 11) ? " PM" : " AM";
hh -= (hh > 12) ? 12 : 0;
hh = (hh<1)?12:((hh<10)?"0"+hh:hh);
var str = "<p>";
str += 'Time: '+hh+':'+mm+':'+ss+' — (-'+ofs+') '+zones[ofs];
str += "</p>";
z[ofs].innerHTML = str;
window.setTimeout("timeZone("+ofs+")", 1000);
}
function startClocks(cnt) {
var i, j=0;
for (i=0; i<cnt; i++) {
z[i] = document.getElementById("zone"+i);
window.setTimeout("timeZone("+i+")", j);
j += 50;
}
return true;
}
window.onload = function() {
return startClocks(11);
}
//-->
</script>
</head>
<body>
<h1>Multi-TimeZone Clocks</h1>
<div id="zone0"><p>Time:</p></div>
<div id="zone1"><p>Time:</p></div>
<div id="zone2"><p>Time:</p></div>
<div id="zone3"><p>Time:</p></div>
<div id="zone4"><p>Time:</p></div>
<div id="zone5"><p>Time:</p></div>
<div id="zone6"><p>Time:</p></div>
<div id="zone7"><p>Time:</p></div>
<div id="zone8"><p>Time:</p></div>
<div id="zone9"><p>Time:</p></div>
<div id="zone10"><p>Time:</p></div>
</body>
</html>
[/code]
But the viewing computer HAS to be set correctly[/QUOTE]
<i>
</i><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Time Zones</title>
<script type="text/javascript">
<!--//
var z = new Array();
var zones = new Array(
"Greenwich Mean Time",
"Azores Time",
"Mid-Atlantic Time",
"Newfoundland Time",
"Atlantic Standard Time",
"Eastern Standard Time",
"Central Standard Time",
"Mountain Standard Time",
"Pacific Standard Time",
"Alaska Standard Time",
"Hawaii Standard Time"
); // no comma after last entry above
function timeZone(ofs) {
var curDate = new Date();
var ss = curDate.getUTCSeconds();
ss = (ss<10)?"0"+ss:ss;
var mm = curDate.getUTCMinutes();
mm = (mm<10)?"0"+mm:mm;
var hh = curDate.getUTCHours();
hh -= ofs;
hh = (hh<0)?hh+24:hh;
ss += (hh > 11) ? " PM" : " AM";
hh -= (hh > 12) ? 12 : 0;
hh = (hh<1)?12:((hh<10)?"0"+hh:hh);
var str = "<p>";
str += 'Time: '+hh+':'+mm+':'+ss+' — (-'+ofs+') '+zones[ofs];
str += "</p>";
z[ofs].innerHTML = str;
window.setTimeout("timeZone("+ofs+")", 1000);
}
function startClocks(cnt) {
var i, j=0;
for (i=0; i<cnt; i++) {
z[i] = document.getElementById("zone"+i);
window.setTimeout("timeZone("+i+")", j);
j += 50;
}
return true;
}
window.onload = function() {
return startClocks(11);
}
//-->
</script>
</head>
<body>
<h1>Multi-TimeZone Clocks</h1>
<div id="zone0"><p>Time:</p></div>
<div id="zone1"><p>Time:</p></div>
<div id="zone2"><p>Time:</p></div>
<div id="zone3"><p>Time:</p></div>
<div id="zone4"><p>Time:</p></div>
<div id="zone5"><p>Time:</p></div>
<div id="zone6"><p>Time:</p></div>
<div id="zone7"><p>Time:</p></div>
<div id="zone8"><p>Time:</p></div>
<div id="zone9"><p>Time:</p></div>
<div id="zone10"><p>Time:</p></div>
</body>
</html>
[CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Time Zones</title>
<script type="text/javascript">
<!--//
var z = new Array();
var zones = new Array(
"Greenwich Mean Time",
"GMT+1",
"GMT+2",
"GMT+3",
"GMT+4",
"GMT+5",
"GMT+6",
"GMT+7",
"Au WA time",
"add 1/2hr for Au CST",
"Au EST",
"Au EDST",
"NZ DST"
); // no comma after last entry above
function timeZone(ofs) {
var curDate = new Date();
var ss = curDate.getUTCSeconds();
ss = (ss<10)?"0"+ss:ss;
var mm = curDate.getUTCMinutes();
mm = (mm<10)?"0"+mm:mm;
var hh = curDate.getUTCHours();
hh += ofs;
hh = (hh<0)?hh+24:hh;
ss += (hh > 11) ? " PM" : " AM";
hh -= (hh > 12) ? 12 : 0;
hh = (hh<1)?12:((hh<10)?"0"+hh:hh);
var str = "<p>";
str += 'Time: '+hh+':'+mm+':'+ss+' — (+'+ofs+') '+zones[ofs];
str += "</p>";
z[ofs].innerHTML = str;
window.setTimeout("timeZone("+ofs+")", 1000);
}
function startClocks(cnt) {
var i, j=0;
for (i=0; i<cnt; i++) {
z[i] = document.getElementById("zone"+i);
window.setTimeout("timeZone("+i+")", j);
j += 50;
}
return true;
}
window.onload = function() {
return startClocks(13);
}
//-->
</script>
</head>
<body>
<h1>Multi-TimeZone Clocks</h1>
<div id="zone0"><p>Time:</p></div>
<div id="zone1"><p>Time:</p></div>
<div id="zone2"><p>Time:</p></div>
<div id="zone3"><p>Time:</p></div>
<div id="zone4"><p>Time:</p></div>
<div id="zone5"><p>Time:</p></div>
<div id="zone6"><p>Time:</p></div>
<div id="zone7"><p>Time:</p></div>
<div id="zone8"><p>Time:</p></div>
<div id="zone9"><p>Time:</p></div>
<div id="zone10"><p>Time:</p></div>
<div id="zone11"><p>Time:</p></div>
<div id="zone12"><p>Time:</p></div>
</body>
</html>[/CODE]
[code=html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Time Zones</title>
<style type="text/css">
<!--
form {
border: 0 solid #808080;
margin: 0;
padding: 0;
}
img {
border: 0 solid #808080;
display: inline;
vertical-align: bottom;
}
table {
border: 0 solid #808080;
border-collapse: collapse;
margin: 0;
padding: 0;
}
tr,div {
border: 0 solid #808080;
margin: 0;
padding: 0;
}
td,th {
border: 0 solid #808080;
font-family: 'Times New Roman', serif;
font-size: 12pt;
margin: 0;
padding-bottom: 2px;
padding-left: 10px;
padding-right: 10px;
padding-top: 2px;
text-align: left;
vertical-align: top;
}
th {
font-size: 24pt;
line-height: 36pt;
text-align: center;
vertical-align: bottom;
}
-->
</style>
<script type="text/javascript">
<!--//
var zones = new Array(
new Array("Greenwich Mean Time", "Greenwich Mean Time"),
new Array("Azores Time", "Berlin, Paris, Warsaw"),
new Array("Mid-Atlantic Time", "Athens, Cairo, Jerusalem"),
new Array("Newfoundland Time", "Baghdad, Moscow, Nairobi"),
new Array("Atlantic Standard Time", "Dhabi, Muscat, Baku"),
new Array("Eastern Standard Time", "Ekaterinburg, Islamabad, Karachi"),
new Array("Central Standard Time", "Almaty, Dhaka, Rangoon"),
new Array("Mountain Standard Time", "Bangkok, Hanoi, Krasnoyarsk"),
new Array("Pacific Standard Time", "Beijing, Kuala Lumpur, Taipei"),
new Array("Alaska Standard Time", "Osaka, Seoul, Yakutsk"),
new Array("Hawaii Standard Time", "Brisbane, Guam, Vladivostok"),
new Array("Midway Island, Samoa", "Magadan, Solomon Islands"),
new Array("Internation Date-Line West", "Aukland, Fiji, Marshall Is.")
); // no comma after last entry above
//
function timeZone(ofs, idx) {
var curDate = new Date();
var ss = curDate.getUTCSeconds();
ss = (ss<10)?"0"+ss:ss;
var mm = curDate.getUTCMinutes();
mm = (mm<10)?"0"+mm:mm;
var hh = curDate.getUTCHours();
if(idx==0) hh -= ofs;
else hh += ofs;
hh = (hh<0)?hh+24:hh;
ss += (hh > 11) ? " PM" : " AM";
hh -= (hh > 12) ? 12 : 0;
hh = (hh<1)?12:((hh<10)?"0"+hh:hh);
var str = "<p>";
str += hh+':'+mm+':'+ss+' — ('+((idx==0)?'-':'+')+ofs+') '+zones[ofs][idx];
str += "</p>";
ztbl.rows[ofs+1].cells[idx].innerHTML = str;
window.setTimeout("timeZone("+ofs+", "+idx+")", 1000);
}
var ztbl = null;
function startClocks(cnt) {
ztbl = document.getElementById("zone_table");
var i, j=0;
for (i=0; i<cnt; i++) {
window.setTimeout("timeZone("+i+", 0)", j);
j += 50;
}
for (i=0; i<cnt; i++) {
window.setTimeout("timeZone("+i+", 1)", j);
j += 50;
}
return true;
}
window.onload = function() {
return startClocks(13);
}
//-->
</script>
</head>
<body>
<table id="zone_table">
<tr><th colspan="2">Multi-TimeZone Clocks</th></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> </td><td> </td></tr>
</table>
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="../images/valid_html.bmp" alt="Valid HTML 4.01!"
style="border:0px none;" width="88" height="31"></a>
</p>
</body>
</html>
[/code]
<i>
</i> for (i=0; i<cnt; i++) {
window.setTimeout("timeZone("+i+", 0)", j);
j += 50;
}
for (i=0; i<cnt; i++) {
window.setTimeout("timeZone("+i+", 1)", j);
j += 50;
}
<i>
</i><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Time Zones</title>
<style type="text/css">
<!--
table {
border: 0 solid #808080;
border-collapse: collapse;
margin: 0;
padding: 0;
}
tr,div {
border: 0 solid #808080;
margin: 0;
padding: 0;
}
td,th {
border: 0 solid #808080;
font-family: 'Times New Roman', serif;
font-size: 12pt;
margin: 0;
padding-bottom: 2px;
padding-left: 10px;
padding-right: 10px;
padding-top: 2px;
text-align: left;
vertical-align: top;
}
th {
font-size: 24pt;
line-height: 36pt;
text-align: center;
vertical-align: bottom;
}
-->
</style>
<script type="text/javascript">
<!--//
var zones = new Array(
new Array("Greenwich Mean Time", "Greenwich Mean Time"),
new Array("Azores Time", "Berlin, Paris, Warsaw"),
new Array("Mid-Atlantic Time", "Athens, Cairo, Jerusalem"),
new Array("Newfoundland Time", "Baghdad, Moscow, Nairobi"),
new Array("Atlantic Standard Time", "Dhabi, Muscat, Baku"),
new Array("Eastern Standard Time", "Ekaterinburg, Islamabad, Karachi"),
new Array("Central Standard Time", "Almaty, Dhaka, Rangoon"),
new Array("Mountain Standard Time", "Bangkok, Hanoi, Krasnoyarsk"),
new Array("Pacific Standard Time", "Beijing, Kuala Lumpur, Taipei"),
new Array("Alaska Standard Time", "Osaka, Seoul, Yakutsk"),
new Array("Hawaii Standard Time", "Brisbane, Guam, Vladivostok"),
new Array("Midway Island, Samoa", "Magadan, Solomon Islands"),
new Array("International Date-Line West", "Aukland, Fiji, Marshall Is.")
); // no comma after last entry above
var ztbl = null, [COLOR=Red]west = 0[/COLOR], [COLOR=Red]east = 1[/COLOR];
//
function timeZone(ofs, [COLOR=Red]dir[/COLOR]) {
var str, curDate = new Date();
var ss = curDate.getUTCSeconds();
ss = (ss<10)?"0"+ss:ss;
var mm = curDate.getUTCMinutes();
mm = (mm<10)?"0"+mm:mm;
var hh = curDate.getUTCHours();
if([COLOR=Red]dir==west[/COLOR]) hh -= ofs;
else hh += ofs;
hh = (hh<0)?hh+24:hh;
ss += (hh > 11) ? " PM" : " AM";
hh -= (hh > 12) ? 12 : 0;
hh = (hh<1)?12:((hh<10)?"0"+hh:hh);
str = hh+':'+mm+':'+ss+' — ('+(([COLOR=Red]dir==west[/COLOR])?'-':'+')+ofs+') '+zones[ofs][[COLOR=Red]dir[/COLOR]];
ztbl.rows[ofs+1].cells[[COLOR=Red]dir[/COLOR]].innerHTML = str;
window.setTimeout("timeZone("+ofs+", "+[COLOR=Red]dir[/COLOR]+")", 1000);
}
function startClocks(cnt) {
ztbl = document.getElementById("zone_table");
var i, j=0;
for (i=0; i<cnt; i++) {
window.setTimeout("timeZone("+i+", [COLOR=Red]west[/COLOR])", j);
j += 50;
}
for (i=0; i<cnt; i++) {
window.setTimeout("timeZone("+i+", [COLOR=Red]east[/COLOR])", j);
j += 50;
}
return true;
}
window.onload = function() {
return startClocks(13);
}
//-->
</script>
</head>
<body>
<table id="zone_table">
<tr><th colspan="2">[COLOR=Blue]West —[/COLOR] Multi-TimeZone Clocks [COLOR=Blue]— East[/COLOR]</th></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
</table>
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="../images/valid_html.bmp" alt="Valid HTML 4.01!"
style="border:0px none;" width="88" height="31"></a>
</p>
</body>
</html>
0.1.9 — BETA 6.17