Tuesday, February 22, 2011

Dropdown of time zones and client-side timezone detection

UPDATE: Here's the code i mentioned I would post: http://makguidetosoft.blogspot.com/2011/02/client-side-timezone-detection-and.html

Using the bottom 2 references + a few others, I plan on pulling a user's time zone when they login, stick it in the Session[] and then use it to convert db stored UTC times to client times. Converting to UTC requires multiplying the offset by -1 and adding it. Converting to local time from the UTC requires just adding the offset. I will post code once I have time to work on that solution.

ASP.NET dropdownlist populated: Download the file from this blog post: http://madskristensen.net/post/List-time-zones-in-ASPNET.aspx

Alot of others can be found on this blog post and in the comments, including HTML, PHP, Java, and C#: http://www.michaelapproved.com/articles/timezone-dropdown-select-list/

The above website also provided javascript for detecting the timezone and setting the value of the HTML drop down. Woot! http://www.michaelapproved.com/articles/timezone-detect-and-ignore-daylight-saving-time-dst

No comments:

Post a Comment

There was an error in this gadget