I'm still quite new to JavaScript so excuse me if my question sounds stupid.
JavaScript is worlds apart from Object Pascal and I'm still finding my way
around.
I'm working on a JavaScript clock that will show the time for all major
Australian cities. I'm not sure how to approach the whole timezone offset
thing. I know there is a function getTimezoneOffset() but I'm not sure how
to implement it.
Here's a piece of code (implementing time for two cities only at this
stage). I would appreciate it someone could demonstrate how I can implement
an offset. Perth is 3 hours (or 180 minutes) behind Sydney, so how could I
implement the time difference?
function SydClock()
{
var SydTime=new Date();
var SydHours=SydTime.getHours();
var SydMins=SydTime.getMinutes();
var SydSecs=SydTime.getSeconds();
if (SydHours>=13)
SydHours-=12;
if (SydHours==0)
SydHours=12;
if (SydSecs<10)
SydSecs="0"+ SydSecs;
if (SydMins<10)
SydMins="0"+ SydMins;
{
ClockFrm.SydDisplay.value=(SydHours + ":"
+ SydMins + ":" + SydSecs);
setTimeout('SydClock()',1000);
}
}
function PerthClock()
{
var PerthTime=new Date();
var PerthHours=PerthTime.getHours();
var PerthMins=PerthTime.getMinutes();
var PerthSecs=PerthTime.getSeconds();
if (PerthHours>=13)
PerthHours-=12;
if (PerthHours==0)
PerthHours=12;
if (PerthSecs<10)
PerthSecs="0"+ PerthSecs;
if (PerthMins<10)
PerthMins="0"+ PerthMins;
{
ClockFrm.PerthDisplay.value=(PerthHours + ":"
+ PerthMins + ":" + PerthSecs);
setTimeout('PerthClock()',1000);
}
}
Thanx in advance!
DeLpHi_gUy
DeLpHi_gUy - 13 Dec 2003 13:09 GMT
OK, I should also mention that some of the other cities are behind by one
and a half and hour hour. For example, Adelaide is 0.5 hours behind Sydney
while Darwin is 1.5 hours behind Sydney. Which means I have to offset the
hours and minutes.
Any tips will be appreciated.
Thx!
> I'm still quite new to JavaScript so excuse me if my question sounds stupid.
> JavaScript is worlds apart from Object Pascal and I'm still finding my way
[quoted text clipped - 56 lines]
>
> DeLpHi_gUy