Converts DateTimeOffset to local time. : DateTimeOffset Calculation « Date Time « C# / C Sharp






Converts DateTimeOffset to local time.

Converts DateTimeOffset to local time.
  

using System;
using System.Globalization;
public class Test
{
   public static void Main()
   { 
        DateTimeOffset originalTime, localTime;
        
        originalTime = new DateTimeOffset(2007, 3, 11, 3, 0, 0, new TimeSpan(-6, 0, 0));
        localTime = originalTime.ToLocalTime();
        Console.WriteLine("Converted {0} to {1}.", originalTime.ToString(), localTime.ToString());   
        
        originalTime = new DateTimeOffset(2007, 3, 11, 4, 0, 0, new TimeSpan(-6, 0, 0));
        localTime = originalTime.ToLocalTime();
        Console.WriteLine("Converted {0} to {1}.", originalTime.ToString(), localTime.ToString());    
   }
}

   
    
  








Related examples in the same category

1.Adds a specified time interval to a DateTimeOffset object.
2.Adds a specified number of whole and fractional days to the current DateTimeOffset object.
3.Add one week to the current date
4.Adds a specified number of whole and fractional hours to the current DateTimeOffset object.
5.Adds a specified number of months to the current DateTimeOffset object.
6.Adds a specified number of years to the DateTimeOffset object.
7.DateTimeOffset Greater Than OperatorDateTimeOffset Greater Than Operator
8.DateTimeOffset Greater Than Or Equal OperatorDateTimeOffset Greater Than Or Equal Operator
9.DateTimeOffset Inequality OperatorDateTimeOffset Inequality Operator
10.DateTimeOffset LessThan OperatorDateTimeOffset LessThan Operator
11.DateTimeOffset Less Than Or Equal OperatorDateTimeOffset Less Than Or Equal Operator
12.Subtracts a DateTimeOffset from another DateTimeOffsetSubtracts a DateTimeOffset from another DateTimeOffset
13.Subtracts a time interval from DateTimeOffsetSubtracts a time interval from DateTimeOffset
14.Gets a DateTime value that represents the Coordinated Universal Time (UTC) date and time from DateTimeOffset