Click to See Complete Forum and Search --> : Accessing time for a give timezone


Amrutha7
12-15-2005, 10:43 PM
Hi all,
I am new to this forum.
I have a problem using javascript.
I want to know whether there is any way to accesss, the current time and offset from GMT for a given timezone id like IST, EST..etc. :confused:

Thanks for any reply.

Amrutha

CrazyMerlin
12-15-2005, 11:45 PM
find a javascript reference site and look up the Date() function

basically...

var now = new Date();

then there are various methods to find parts of the date including the timezone offset, date from GMT or UTC, and all sorts of things.


~~CM!

Amrutha7
12-16-2005, 12:08 AM
yes there are funtions to find offset (i.e., getTimeZoneOffset() ) But it takes the system timezone into account.
I need to find offset for any selected time zone from a drop down menu.
Please help me if anybody could.

Amrutha

Kor
12-16-2005, 07:10 AM
I need to find offset for any selected time zone from a drop down menu.

You must set manually those values. The browser's interpretor has no built-in function to associate a string as, let's say, "Brisbane" with it's GMT value -10

felgall
12-16-2005, 02:58 PM
Brisbane is +10 not -10.

Charles
12-16-2005, 03:12 PM
Brisbane is +10 not -10.What about daylight and standard time?

Juuitchan
12-17-2005, 01:31 PM
This is a very thorny subject indeed.

The method which I would recommend would be for you to do your own research on dates and times, and then roll your own algorithm.

JPnyc
12-17-2005, 01:34 PM
Why not just assume the user's system time is correct for their time zone, and grab that?

felgall
12-17-2005, 01:59 PM
What about daylight and standard time?

Brisbane doesn't use daylight saving as it is too close to the equator to make it useful.

For those places that do use daylight saving time the main issue is determining when it starts and finishes as this can vary significantly between locations and some locations are even inconsistent from one year to the next.

Why not just assume the user's system time is correct for their time zone, and grab that?

Since all calculations of time in Javascript are derived from that time you have to assume that it is correct as your starting point since any results will be out if it is wrong regardless of what time manipulations you are trying to do.