Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Timezones in Windows

Back to Forum: Tech Off
  • User profile image
    Stitch 2.0

    Hi guys,

    we're have been relying on the Timezone information inside the Windows registry pretty heavily.
    To identify the time zones, we have used the index that is stored in the registry.

    However, we have now found several problems with that:

    • In Windows Vista, the index no longer exists and we couldn't find any definite way to identify each zone.
    • Depending on which version of Windows (Server and Client) our application is running on, there are different time zones in the registry. Some zones only exist in XP, but not on the server.

    When searching the internet for a secure way to rely on the info, always the same piece of code shows up.
    This is how we have used this piece of code so far:

    ArrayList zones = new ArrayList();
    using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones"))
       string[] zoneNames = key.GetSubKeyNames();
       foreach(string zoneName in zoneNames)
          using(RegistryKey subKey = key.OpenSubKey(zoneName))
                TimeZoneInformation tzi = new TimeZoneInformation();
       = zoneName;
                tzi.displayName = (
                tzi.standardName = (
                tzi.daylightName = (
                tzi.index =
             catch (Exception ex) { }

    TimeZoneInformation[] availableZones = new TimeZoneInformation[zones.Count];

    However, this piece of code won't work on Vista or Server 2003 Enterprise...

    Any ideas what info one should rely on when using Timezones?


  • User profile image
  • User profile image

    Theres some demo code on msdn at

    Converting Time Zones

    To get it to work on Vista, I just comented out the line of code that queried the registry for the time zone index( TimeZoneIndex.cs Line:145)

    And I had to tweak couple of strings in the TestTimeZone method because it was very specific on its search names.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.