TimeZoneInfo.Id Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the time zone identifier.
public:
property System::String ^ Id { System::String ^ get(); };
public string Id { get; }
member this.Id : string
Public ReadOnly Property Id As String
The time zone identifier.
The following example lists the identifier of each of the time zones defined on the local computer.
ReadOnlyCollection<TimeZoneInfo> zones = TimeZoneInfo.GetSystemTimeZones();
Console.WriteLine("The local system has the following {0} time zones", zones.Count);
foreach (TimeZoneInfo zone in zones)
Console.WriteLine(zone.Id);
let zones = TimeZoneInfo.GetSystemTimeZones()
printfn $"The local system has the following {zones.Count} time zones"
for zone in zones do
printfn $"{zone.Id}"
Dim zones As ReadOnlyCollection(Of TimeZoneInfo) = TimeZoneInfo.GetSystemTimeZones()
Console.WriteLine("The local system has the following {0} time zones", zones.Count)
For Each zone As TimeZoneInfo In zones
Console.WriteLine(zone.Id)
Next
The time zone identifier is a key string that uniquely identifies a particular time zone. On Windows systems, it corresponds to the subkeys of the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Time Zone branch of the registry on Windows systems and from the ICU Library on Linux and macOS. It can be passed as a parameter to the FindSystemTimeZoneById method to instantiate a TimeZoneInfo object that represents a particular time zone.
Important
Although a key name in the Windows registry can be a maximum of 255 characters, we recommend that an identifier that you assign to a custom time zone be 32 characters or fewer. The longer the identifier, the greater the probability that an incorrect key name will be supplied when retrieving it.
The value of the Id property is usually, but not always, identical to that of the StandardName property. The identifier of the Coordinated Universal Time zone is UTC.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: