C# TimeZoneInfo ConvertTimeBySystemTimeZoneId(DateTimeOffset, String)

Description

TimeZoneInfo ConvertTimeBySystemTimeZoneId(DateTimeOffset, String) converts a time to the time in another time zone based on the time zone's identifier.

Syntax

TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset, String) has the following syntax.


public static DateTimeOffset ConvertTimeBySystemTimeZoneId(
  DateTimeOffset dateTimeOffset,
  string destinationTimeZoneId
)

Parameters

TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset, String) has the following parameters.

  • dateTimeOffset - The date and time to convert.
  • destinationTimeZoneId - The identifier of the destination time zone.

Returns

TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset, String) method returns The date and time in the destination time zone.

Example


using System;/*  w w  w  .ja  va2s  . c o m*/
public class MainClass
{
    public static void Main(String[] argv)
    {
        DateTimeOffset hwTime = DateTimeOffset.Now;

        TimeZoneInfo hwZone = TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time");
        Console.WriteLine(TimeZoneInfo.ConvertTimeBySystemTimeZoneId(hwTime, "Hawaiian Standard Time"));

    }
}

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