views:

61

answers:

2

Hi All,

To get the correct timezone of the user I get the offset first using javascript:-

var offset =new Date().getTimezoneOffset();

and then I apply assign the value to the server side variable.

where I get the timezone using :-

 ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();

 foreach (TimeZoneInfo timeZone in timeZones)
 {
      if (timeZone.BaseUtcOffset.Equals(offset))
      {
                    return timeZone.Id;
      }
 }

Now the problem is that:-

  • there are more than one timezones with same offset so how do I differentiate the timezone for the user.
  • for GMT dublin,edingurgh,edson and london timezone there are two offsets depending on whether is allows day light saving mode(-60 and 0),how do I get the correct offset.

Any Ideas how I can get the correct timezone and offset?

A: 

I am not that familiar with timezones (I thought that a certain timezone could have an unique offset, but this appears to be incorrect). But I found a nice article about timezones calculations and heuristics posted on 4guysfromrolla - hope it is helpful.

Dick

Dick Lampard
A: 

To get the correct timezone as well as offset, you would need to use their IP address and another service that has the timezone information based upon IP and calculate that way.

TheGeekYouNeed