Create time zone from identifier, an offset from (UTC), a display name, and a standard time display name in CSharp

Description

The following code shows how to create time zone from identifier, an offset from (UTC), a display name, and a standard time display name.

Example


/*from  w w  w  .  j  a  v  a  2  s .co m*/
using System;
public class MainClass{
  public static void Main(String[] argv){  

    string displayName = "(GMT+06:00) Antarctica/Mawson Time";
    string standardName = "Mawson Time"; 
    TimeSpan offset = new TimeSpan(06, 00, 00);
    TimeZoneInfo mawson = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName);
    Console.WriteLine("The current time is {0} {1}", 
                      TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, mawson),
                      mawson.StandardName);

  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var