DateTime Struct

Work with dates and time in .NET.

We'll cover the following

Overview

The DateTime struct (value type) can represent any date and time between 00:00:00 01.01.0001 (January 1st, 0001) and 23:59:59 31.12.9999 (December 31st, 9999).

Note: The DateTime struct follows the Gregorian calendar, introduced on October 15th, 1582, and this fact should be considered if our application works with dates before that.

Syntax

Just like other types in .NET, DateTime has a constructor. To create a DateTime variable, we can use one of its constructors:

Get hands-on with 1400+ tech skills courses.