Closed Thread Icon

Preserved Topic: Live clock with multiple time zones (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=7841" title="Pages that link to Preserved Topic: Live clock with multiple time zones (Page 1 of 1)" rel="nofollow" >Preserved Topic: Live clock with multiple time zones <span class="small">(Page 1 of 1)</span>\

 
patric design
Bipolar (III) Inmate

From: 290 km/h, fast lane, Autobahn, Germany
Insane since: Feb 2001

posted posted 09-14-2001 23:04

Does anyone have a code which displays the server time and dependent on that calculates 2 other clocks. What I need is one live clock to show server time (Germany) and then next to it there should be Boston time and lets say London time? I also need it to show a 24hr-clock, not AM or PM?

<´¯`·.¸ Patric ¸.·´¯`>

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-14-2001 23:28

This is actually something that needs to be done on the server side. (If you want the server time) If you want them to be fully functioning it will be a combination of server side and DHTML

I think you are using ASP from one of your other posts.
I'm not really familiar with the Clock functions in ASP so I can't be much help there



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-15-2001 00:44

On the other hand, if you're assuming the viewer's clock is set correctly, then you can get their time zone with the following code:

var rightNow = new Date();
var timezoneOffset = rightNow.getTimezoneOffset();

then timezoneOffset contains the number of minutes difference between Greenwich Mean Time and the local time zone. It's measured in minutes and not hours because some countries are in time zones that aren't offset by an exact number of hours.

You can use that, along with the other methods of the Date object, to display the times you want to display, again, assuming the viewer has their clock set correctly.

patric design
Bipolar (III) Inmate

From: 290 km/h, fast lane, Autobahn, Germany
Insane since: Feb 2001

posted posted 09-15-2001 01:05

Well it would be nice to have this on a website, but it was actually meant to be for my desktop ;-)

I just wanted it to look like this:

Berlin: 20:00
London 19:00
Boston 14:00 (or whatever, not sure about the time diff.)

so it doesnt actually NEED to be based on server time. However they should be live clocks...

<´¯`·.¸ Patric ¸.·´¯`>

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-15-2001 01:33

Ah well that's easier.


something like this should work (I'm only worrying about IE since this is a desktop script)
<html>
<head>
<script>
/*
These values should be the difference between where you are and where you want the time to be
*/
var timezoneoffset1 = 3
var timezoneoffset2 = -3

function GetTheTime(){
now = new Date()
hour = now.getHours();
hour1 = hour + timezoneoffset1;
hour2 = hour + timezoneoffset2;
minutes = now.getMinutes();
secs = now.getSeconds();

zero = ""
if (minutes < 10) zero = "0";
minutes = zero+""+minutes;

dateDIV.innerHTML = "berlin: " +hour+ ":" +minutes+ "<br> Location1: " +hour1+ ":" +minutes+ "<br>Location2: " +hour2+ ":" +minutes;

myoffset = 60000 - (secs * 1000);
setTimeout('GetTheTime()',myoffset);


}
</script>
</head>
<body onload="GetTheTime()">
<div id="dateDIV">The date</div>

</body>
</html>



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

[This message has been edited by bitdamaged (edited 09-15-2001).]

[This message has been edited by bitdamaged (edited 09-15-2001).]

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-15-2001 02:00

As a note I would not use seconds in this script it would make the function run once a second which may get processor intensive.




:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

[This message has been edited by bitdamaged (edited 09-15-2001).]

« BackwardsOnwards »

Show Forum Drop Down Menu