Offset of DateTime : Date Time : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Date Time »

 

Offset of DateTime








    
 
using System;
public class MainClass {
    public static void Main() {

        DateTimeOffset local = DateTimeOffset.Now;
        DateTimeOffset utc = local.ToUniversalTime();

        Console.WriteLine(local.Offset);   // -06:00:00 (in Central America)
        Console.WriteLine(utc.Offset);     // 00:00:00

        Console.WriteLine(local == utc);                 // True
        //To include the Offset in the comparison, you must use the EqualsExact method:
        Console.WriteLine(local.EqualsExact(utc));      // False
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Date Time