CSharp - DateTimeOffset and Time Zones

Introduction

DateTimeOffset instance value comparisons honor the time zone difference.

ToUniversalTime/ToLocalTime methods return a DateTimeOffset representing the same point in time, but with a UTC or local offset.

Demo

using System;
class MainClass/*from w ww . j  av  a2 s . co m*/
{
   public static void Main(string[] args)
   {

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

     Console.WriteLine (local.Offset);  
     Console.WriteLine (utc.Offset);    

     Console.WriteLine (local == utc);  

     //To include the Offset in the comparison, you must use the  EqualsExact method:

     Console.WriteLine (local.EqualsExact (utc));
   }
}

Result