Get DateTimeOffset in current date and time with offset set to local time's offset from Coordinated Universal Time (UTC) in CSharp

Description

The following code shows how to get DateTimeOffset in current date and time with offset set to local time's offset from Coordinated Universal Time (UTC).

Example


using System;//  w ww.  j ava  2s  . c  om

public class Example
{
   public static void Main()
   {
      String[] fmtStrings = { "d", "D", "f", "F", "g", "G", "M", 
                              "R", "s", "t", "T", "u", "y" };

      DateTimeOffset value = DateTimeOffset.Now;
      foreach (var fmtString in fmtStrings)
         Console.WriteLine("{0} --> {1}", 
                           fmtString, value.ToString(fmtString));
   }
}

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