Essential Types C# Book

Get data and time properties from DateTime and DateTimeOffset
using System;
using System.Text;
class Sample
{
public static void Main()
{
DateTime dt = new DateTime(2010, 12, 13, 10, 20, 30);
Console.WriteLine(dt.Year);
Console.WriteLine(dt.Month);
Console.WriteLine(dt.Day);
Console.WriteLine(dt.DayOfWeek);
Console.WriteLine(dt.DayOfYear);
Console.WriteLine(dt.Hour);
Console.WriteLine(dt.Minute);
Console.WriteLine(dt.Second);
Console.WriteLine(dt.Millisecond);
Console.WriteLine(dt.Ticks);
Console.WriteLine(dt.TimeOfDay);
}
}
The output:
2010
12
13
Monday
347
10
20
30
0
634278324300000000
10:20:30