Tech Off Post

Single Post Permalink

View Thread: Timezones in Windows
  • 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?