C# TimeZoneInfo FindSystemTimeZoneById

Description

TimeZoneInfo FindSystemTimeZoneById retrieves a TimeZoneInfo object from the registry based on its identifier.

Syntax

TimeZoneInfo.FindSystemTimeZoneById has the following syntax.


public static TimeZoneInfo FindSystemTimeZoneById(
  string id
)

Parameters

TimeZoneInfo.FindSystemTimeZoneById has the following parameters.

  • id - The time zone identifier, which corresponds to the Id property.

Returns

TimeZoneInfo.FindSystemTimeZoneById method returns An object whose identifier is the value of the id parameter.

Example

The following example uses the FindSystemTimeZoneById method to retrieve the Tokyo Standard Time zone.


/*from  w  ww  .jav a  2 s.co  m*/
using System;

public class Example
{
   public static void Main()
   {
      DateTime thisTime = DateTime.Now;

      // Get Tokyo Standard Time zone
      TimeZoneInfo tst = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
      DateTime tstTime = TimeZoneInfo.ConvertTime(thisTime, TimeZoneInfo.Local, tst);      


   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version