C# DateTimeOffset TimeOfDay

Description

DateTimeOffset TimeOfDay gets the time of day for the current DateTimeOffset object.

Syntax

DateTimeOffset.TimeOfDay has the following syntax.


public TimeSpan TimeOfDay { get; }

Example

The following example uses the TimeOfDay property to extract the time and display it to the console.


//from www .j  a v a  2s  . co  m
using System;

public class MainClass{
  public static void Main(String[] argv){  
    DateTimeOffset currentDate = new DateTimeOffset(2014, 5, 10, 5, 32, 16, 
                                          DateTimeOffset.Now.Offset); 
    TimeSpan currentTime = currentDate.TimeOfDay;
    Console.WriteLine("The current time is {0}.", currentTime.ToString());

  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version