JavaScript - Current Time

J

JCO

I have a script that calculates the current time. It is off by 1 hour. I
was looking at the code and questioning the line that sets the Time Zone.
My time zone is Central. In the code it sets the timezone to 6. How do
figure out if this is correct?
 
R

Ronx

If Central is the same time zone as Alabama, then it looks as if the
JavaScript time zone is the number of hours behind UCT (aka GMT) - Alabama
is 6 hours behind GMT.
 
J

JCO

So then I can change the timezone by one hour to fix the problem. I assume,
when we fall back an hour, that I will NOT have to make another change. I'm
in Texas... Central Time Zone.
 
R

Ronx

Texas spans two time zones - 6 and 7 hours behind GMT. I do not know which
is Central.

JavaScript takes its time from the PC's system clock. It is possible that
the one hour time difference is because Windows is displaying Daylight
Saving time, whereas the system clock is at "normal" time. If this is the
case then the time difference will correct itself at the end of October,
when the clocks go back, and reappear next spring.
 
J

JCO

I'm in the DFW area which is Central US Time.
The problem is that the number has to be 5 to make it work correctly.
My clock is set to GMT 6.
 
R

Ronx

Let me clarify -
Your PC clock is set to GMT -6
Working correctly - is the time displayed GMT -6, or does the time displayed
allow for daylight saving, and show GMT -5? (which explains the JavaScript
setting of 5 to make that match the displayed clock).

Time Zones, coupled with daylight saving, can be confusing. I've worked
with Time Zones around the world for 30 years and still get confused,
especially when different countries in different hemispheres change from
daylight saving to normal, or vice versa, on different dates!
 
Top