Get DateTime value that represents the date and time of the current DateTimeOffset in CSharp

Description

The following code shows how to get DateTime value that represents the date and time of the current DateTimeOffset.

Example


using System;/*from  w w w . j  av a2  s.  com*/

public class MainClass{
  public static void Main(String[] argv){  
    DateTimeOffset offsetDate; 
    DateTime regularDate;
    
    offsetDate = DateTimeOffset.Now;
    regularDate = offsetDate.DateTime;
    Console.WriteLine("{0} converts to {1}, Kind {2}.", 
                      offsetDate.ToString(), 
                      regularDate,  
                      regularDate.Kind);
    
  }
}

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