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.