JavaScript - Current Time

  • Thread starter Thread starter JCO
  • Start date Start date
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?
 
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.
 
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.
 
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.
 
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.
 
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top