C# – Working with Date and Times

If you follow me a bit,  you are aware of that I jump directly into the subject without saying much so let’s go on.

In order to create a new DateTime object 

DateTime myDateTime = DateTime.Now;

DateTime myDateTime  = DateTime("12/01/1980");


Formatting ….. many options;


Retrieving parts;

myDateTime.Year  // int

myDateTime.Hour // int

myDateTime.DayOfWeek //Monday

myDateTime.DayOfYear //int 1981


DateTime Math:



“Chaining” = using multiple methods together with . operator






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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: