Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getTimezoneOffset() baffles me 1

Status
Not open for further replies.

SCelia

Programmer
Feb 27, 2002
82
CA
Ok I find this handy little function that returns the difference in minutes from GMT. I run it tho and I get 420, i.e 7 hours. I'm 8 hours off GMT (PST). So I change the time zone on my computer to GMT and run the program again. -60. Wierd, so I just need to add 60 to it for some reason. I set the time zone to 1 hour off GMT and I get 60. (add 60 to that and I have 120, which is messed up). I can't make any sense of this. How am I supposed to use getTimezoneOffset to find the timezone of the client? Celia
 
The odd hour is likely an adjustment for Daylight Savings Time. You are in the Pacific Standard Time zone but your computer is reporting Pacific Daylight Time (and will for another 4 weeks or so). My understanding is GMT is never adjusted for daylight savings which probably accounts for the -60.

Any calculation using TimezoneOffset to conjure the client's time zone will have to account for daylight savings time adjustments. It may be easier use Date.toString() to get time zone -- for most platforms toString() includes the time zone.
 
Thanks mate, that solved the problems. Celia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top