This documentation is archived and is not being maintained.

How to: Create Time Zones Without Adjustment Rules

The precise time zone information that is required by an application may not be present on a particular system for several reasons:

  • The time zone has never been defined in the local system's registry.

  • Data about the time zone has been modified or removed from the registry.

  • The time zone exists but does not have accurate information about time zone adjustments for a particular historic period.

In these cases, you can call the CreateCustomTimeZone method to define the time zone required by your application. You can use the overloads of this method to create a time zone with or without adjustment rules. If the time zone supports daylight saving time, you can define adjustments with either fixed or floating adjustment rules. (For definitions of these terms, see the "Time Zone Terminology" section in Time Zone Overview.)

Important noteImportant

Custom time zones created by calling the CreateCustomTimeZone method are not added to the registry. Instead, they can be accessed only through the object reference returned by the CreateCustomTimeZone method call.

This topic shows how to create a time zone without adjustment rules. To create a time zone that supports daylight saving time adjustment rules, see How to: Create Time Zones with Adjustment Rules.

To create a time zone without adjustment rules

  1. Define the time zone's display name.

    The display name follows a fairly standard format in which the time zone's offset from Coordinated Universal Time (UTC) is enclosed in parentheses and is followed by a string that identifies the time zone, one or more of the cities in the time zone, or one or more of the countries or regions in the time zone.

  2. Define the name of the time zone's standard time. Typically, this string is also used as the time zone's identifier.

  3. If you want to use a different identifier than the time zone's standard name, define the time zone identifier.

  4. Instantiate a TimeSpan object that defines the time zone's offset from UTC. Time zones with times that are later than UTC have a positive offset. Time zones with times that are earlier than UTC have a negative offset.

  5. Call the TimeZoneInfo.CreateCustomTimeZone(String, TimeSpan, String, String) method to instantiate the new time zone.

The following example defines a custom time zone for Mawson, Antarctica, which has no adjustment rules.

Dim displayName As String = "(GMT+06:00) Antarctica/Mawson Time"
Dim standardName As String = "Mawson Time" 
Dim offset As TimeSpan = New TimeSpan(06, 00, 00)
Dim mawson As TimeZoneInfo = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName)
Console.WriteLine("The current time is {0} {1}", _ 
                  TimeZoneInfo.ConvertTime(Date.Now, TimeZoneInfo.Local, mawson), _

The string assigned to the DisplayName property follows a standard format in which the time zone's offset from UTC is followed by a friendly description of the time zone.

This example requires:

  • That a reference to System.Core.dll be added to the project.

  • That the following namespaces be imported:

    Imports System.Collections.Generic
    Imports System.Collections.ObjectModel