Get the time's offset from Coordinated Universal Time (UTC) in CSharp
Description
The following code shows how to get the time's offset from Coordinated Universal Time (UTC).
Example
/*from w w w.ja v a 2 s. co m*/
using System;
public class MainClass{
public static void Main(String[] argv){
DateTimeOffset localTime = DateTimeOffset.Now;
Console.WriteLine("The local time zone is {0} hours and {1} minutes {2} than UTC.",
Math.Abs(localTime.Offset.Hours),
localTime.Offset.Minutes,
localTime.Offset.Hours < 0 ? "earlier" : "later");
}
}
The code above generates the following result.