[edit] C# TimeSpan TimeOfDay Property
The TimeSpan TimeOfDay property simply returns a TimeSpan value representing the interval that have passed since 12 midnight.
[edit] Syntax
TimeSpan variable = date.TimeOfDay;
[edit] Example
using System;
class Program
{
static void Main()
{
DateTime date = DateTime.Now;
TimeSpan tod = date.TimeOfDay;
Console.WriteLine(tod.ToString());
Console.Read();
}
}
Output:
13:45:12.1730271
- 13 hours 45 min and 12.1730271 seconds have passed since midnight.
The results will vary depending on when you run this code.
<= DateTime Tutorial
|