#81 – DateTime and TimeSpan Types

You can use the DateTime type to represent a specific date and time, and the TimeSpan type to represent a particular length of time.

Examples of DateTime values:

 DateTime dt1 = new DateTime(1963, 11, 22);   // 22-Nov-1963
 DateTime dt2 = new DateTime(2001, 9, 11, 9, 59, 0);  // 11-Sep-2001, 9:59AM

Examples of TimeSpan values:

 TimeSpan ts1 = new TimeSpan(33, 30, 29);  // 33 hrs, 30 mins, 29 secs
 TimeSpan ts2 = new TimeSpan(2174, 0, 0, 0);        // 2174 days