Click to See Complete Forum and Search --> : Timezone Help Please
Lana Tran
12-11-2002, 10:05 AM
Hi,
I would really appreciate if someone could please provide me some info about timezone:
1. When I use getTimezoneOffset(), it returns the offset from GMT with DST (Daylight Saving Time) taking into account. In other words, the offset is adjusted in April and October since the PC's clock is selected for DST adjustment. However, my application requires the standard/fixed timezone offset. Is there a way to get the fixed timezone offset?
2. Is there a way to find out the timezone (CST, EST, …) on the client’s PC?
Thank you.
gil davis
12-11-2002, 12:00 PM
Time is relative. Your time is not exactly the same as my time, and your time means very little to me unless I owe you money and it is due at a certain time based on your time.
Originally posted by Lana Tran
1. When I use getTimezoneOffset(), it returns the offset from GMT with DST (Daylight Saving Time) taking into account ... However, my application requires the standard/fixed timezone offset. Is there a way to get the fixed timezone offset?
The DST is a client configuration offset, and you cannot change that. His time rules are just that - his. Anything that you do with time zones and offsets will just confuse him. You should really think about what you need your application to do. Whey are you trying to mess with someone else's time?
2. Is there a way to find out the timezone (CST, EST, …) on the client’s PC?
By executing getTimezoneOffset(), you (actually your page, you don't have any say in the matter) *do* get his offset.
If *you* run your page, you will get *your* time zone offset. If *I* run your page, I will get *my* time zone offset.
Lana Tran
12-11-2002, 12:55 PM
Our application has to support world wide (multiple time zones). We have a central database and it stores user input time fields in GMT. On the client's browser, the time fields are in local time. Behind the scene, it automatically converts from GMT to local (using the time zone offset) or vice versa. Let me give an example so you can see our problem. The client's PC was on Central time and it was in May (DST) and he entered 11:00. It got converted and stored in the database as 16:00 because 11:00 + 5:00 (offset). The user was happy all the way to Oct. In Nov, it went back to CST, not DST anymore, and it displayed 10:00 instead of 11:00 because it retrieved 16:00 from the database and converted to 10:00 (16:00 - 6:00 (offset)). The user wants 11:00, not 10:00. One of the solutions is to have a drop-down box to ask the user to select his/her time zone (with hard code fixed offset). I was just wondering if there was another way to avoid hard code.
gil davis
12-11-2002, 01:14 PM
If you convert the time to a UTC date object, the browser will compensate for the offsets automatically.
Or don't you keep the date as well as the time of day?
var then = new Date(yr_num, mo_num, day_num, hr_num, min_num, sec_num, ms_num);