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.