Get DateTimeOffset whose date and time set to current Coordinated Universal Time (UTC) and whose offset is TimeSpan.Zero in CSharp
Description
The following code shows how to get DateTimeOffset whose date and time set to current Coordinated Universal Time (UTC) and whose offset is TimeSpan.Zero.
Example
using System;// ww w . j a v a 2 s . c o m
public class MainClass{
public static void Main(String[] argv){
DateTimeOffset localTime = DateTimeOffset.Now;
DateTimeOffset utcTime = DateTimeOffset.UtcNow;
Console.WriteLine("Local Time: {0}", localTime.ToString("T"));
Console.WriteLine("Difference from UTC: {0}", localTime.Offset.ToString());
Console.WriteLine("UTC: {0}", utcTime.ToString("T"));
}
}
The code above generates the following result.