#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

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: