Click to See Complete Forum and Search --> : world clock help help!
yumyum
11-21-2004, 06:05 AM
Hi. I'm trying' to put world clock on the website.
This site's script seems easy and perfect,
http://javascript.internet.com/clocks/world-clock.html
but the problrm is that I ONLY need London&Tokyo times.
I paste these code into Dreamweaver, and simply erased all the other lines in BODY tag, then I previewed in IE and NO time is shown, just texts and text fields.
I may need to make changes inside the scripts in HEAD tag, but as I am truly newbee to Javascripts, I have no clue how I can solve this problem.
Please Please someone help me! ASAP!
many thanx*
vwphillips
11-21-2004, 02:57 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<!-- THREE STEPS TO INSTALL WORLD CLOCK:
1. Copy the coding into the HEAD of your HTML document
2. Add the onLoad event handler into the BODY tag
3. Put the last coding into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Emanuel Gavrilv (eltal@sprint.ca) -->
<!-- Web Site: http://www.angelfire.com/on/eltal -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function GetTime() {
var dt = new Date();
var def = dt.getTimezoneOffset()/60;
var gmt = (dt.getHours() + def);
document.clock.local.value = (IfZero(dt.getHours()) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));
var ending = ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds());
var tky =check24(((gmt + 9) > 24) ? ((gmt + 9) - 24) : (gmt + 9)); // required
document.clock.tky.value = (IfZero(tky) + ending);
var _GMT =check24(((gmt) > 24) ? ((gmt) - 24) : (gmt));
document.clock._GMT.value = (IfZero(_GMT) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));
setTimeout("GetTime()", 1000);
}
function IfZero(num) {
return ((num <= 9) ? ("0" + num) : num);
}
function check24(hour) {
return (hour >= 24) ? hour - 24 : hour;
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->
<BODY onLoad="javascript:GetTime();">
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<center>
<form name="clock">
<strong>Local Time <input type="text" size="8" name="local"></strong>
<p>
<p>
<strong>Greenwich Mean Time (GMT) <input type="text" size="8" name="_GMT"></strong>
<p>
Tokyo (GMT +9) <input type="text" size="8" name="tky">
<p>
</form>
</center>
<p><center>
<font face="arial, helvetica" SIZE="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 5.96 KB -->
</body>
</html>
remove any spaces between java & script
Charles
11-21-2004, 04:17 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>
<script type="text/javascript">
<!--
Date.londonOffset = 0;
Date.tokyoOffset = +9;
Date.ONE_SECOND = 1000;
Date.ONE_MINUTE = Date.ONE_SECOND * 60;
Date.ONE_HOUR = Date.ONE_MINUTE * 60;
Date.prototype.toUTCOffset = function (offset) {return new Date(this.getTime() + this.getTimezoneOffset() * 60000 + offset * Date.ONE_HOUR)}
Date.prototype.toTimeString = function () {return [this.getHours() < 13 ? this.getHours() : this.getHours() - 12, this.getMinutes() < 10 ? '0' + this.getMinutes() : this.getMinutes(), this.getSeconds() < 10 ? '0' + this.getSeconds() : this.getSeconds()].join (':') + (this.getHours() < 13 ? ' AM' : ' PM')}
// -->
</script>
</head>
<body>
<script type="text/javascript">
<!--
document.write('<dl>');
document.write('<dt>London</dt>');
document.write('<dd id="london">', new Date().toUTCOffset(Date.londonOffset).toTimeString(), '</dd>');
document.write('<dt>Tokyo</dt>');
document.write('<dd id="tokyo">', new Date().toUTCOffset(Date.tokyoOffset).toTimeString(), '</dd>');
document.write('</dl>');
if (document.getElementById) setInterval("document.getElementById('london').firstChild.data = new Date().toUTCOffset(Date.londonOffset).toTimeString(); document.getElementById('tokyo').firstChild.data = new Date().toUTCOffset(Date.tokyoOffset).toTimeString()", 0.2 * Date.ONE_SECOND);
// -->
</script>
</body>
</html>
yumyum
11-22-2004, 03:20 AM
Thanx thanx very much for your great help!!
It's amazing how you guys can come up with solution sooo quickly...Bless.
7stud
11-22-2004, 05:43 AM
but as I am truly newbee to Javascripts,
:confused: :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>
<script type="text/javascript">
<!--
Date.londonOffset = 0;
Date.tokyoOffset = +9;
Date.ONE_SECOND = 1000;
Date.ONE_MINUTE = Date.ONE_SECOND * 60;
Date.ONE_HOUR = Date.ONE_MINUTE * 60;
Date.prototype.toUTCOffset = function (offset) {return new Date(this.getTime() + this.getTimezoneOffset() * 60000 + offset * Date.ONE_HOUR)}
Date.prototype.toTimeString = function () {return [this.getHours() < 13 ?
this.getHours() : this.getHours() - 12,
this.getMinutes() < 10 ? '0' + this.getMinutes() : this.getMinutes(),
this.getSeconds() < 10 ? '0' + this.getSeconds() : this.getSeconds()].join (':') + (this.getHours() < 13 ? ' AM' : ' PM')}
// -->
</script>
</head>
<body>
<script type="text/javascript">
<!--
document.write('<dl>');
document.write('<dt>London</dt>');
document.write('<dd id="london">', new Date().toUTCOffset(Date.londonOffset).toTimeString(), '</dd>');
document.write('<dt>Tokyo</dt>');
document.write('<dd id="tokyo">', new Date().toUTCOffset(Date.tokyoOffset).toTimeString(), '</dd>');
document.write('</dl>');
if (document.getElementById) setInterval("document.getElementById('london').firstChild.data =
new Date().toUTCOffset(Date.londonOffset).toTimeString(); document.getElementById('tokyo').firstChild.data =
new Date().toUTCOffset(Date.tokyoOffset).toTimeString()", 0.2 * Date.ONE_SECOND);
// -->
</script>
</body>
</html>
yumyum
11-23-2004, 07:26 AM
sorry, this is me again,
I tried all scripts you have given so far, but only Charles' one did work.
so I want to use your script Charles, but I want to put London/Tokyo times separately in different raw/column - as I have images to go along with each times.
Is that possible?
If so, please teach me how to. I tried it by myself but I made absolute mess.
or, I need someone to give me another script which enable me to do what I said above.
mmmany thanx!
bazjones
11-23-2004, 07:41 AM
Why sont you create a new html page is dreamweaver and paste the code in there with none on the html, head or body tags. The just use a server side includes, there will then not be as much code to wade through for your website go to insert - script objects - server side includes and point to the new page you created for your script!!
Charles
11-23-2004, 07:41 AM
My script is easily adapted. Please post how you want the HTML to look, having first run the HTML through The Validator (http://validator.w3.org/) and making sure that you do not use TABLEs for layout.
Charles
11-23-2004, 07:42 AM
Originally posted by bazjones
Why sont you create a new html page is dreamweaver and paste the code in there with none on the html, head or body tags. The just use a server side includes, there will then not be as much code to wade through for your website go to insert - script objects - server side includes and point to the new page you created for your script!! The problem is that Dreamweaver doesn't produce HTML.