C#DateTimenew DateTime
DateTime.Today

new DateTimeDateTime

AddYears

Initializes a new DateTime with specified year, month, and day.

Syntax

new DateTime(year, month, day)

Example

Enter values below to update the example in real time.

dt
new
Console
WriteLine
ToString
DateTime dt = new DateTime(2024, 6, 15);
Console.WriteLine(dt.ToString("yyyy-MM-dd"));   // "2024-06-15"