Get a DateTime that represents the Coordinated Universal Time (UTC) of the current DateTimeOffset in CSharp

Description

The following code shows how to get a DateTime that represents the Coordinated Universal Time (UTC) of the current DateTimeOffset.

Example


using System;/*from   w w  w.  ja  va 2s  . c o m*/

public class MainClass{
  public static void Main(String[] argv){  
    DateTimeOffset offsetTime = new DateTimeOffset(2014, 11, 25, 11, 14, 00, 
                                new TimeSpan(3, 0, 0));
    Console.WriteLine("{0} is equivalent to {1} {2}", 
                      offsetTime.ToString(), 
                      offsetTime.UtcDateTime.ToString(), 
                      offsetTime.UtcDateTime.Kind.ToString());      
    

  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var