C#DateTimeToString
Subtract

ToStringDateTime

DayOfWeek

Converts the value of the current DateTime to its equivalent string representation.

Syntax

dt.ToString(format?)

Example

Enter values below to update the example in real time.

dt
new
Console
WriteLine
ToString
DateTime dt = new DateTime(2024, 6, 15, 14, 30, 0);
Console.WriteLine(dt.ToString("yyyy-MM-dd"));         // "2024-06-15"
Console.WriteLine(dt.ToString("yyyy-MM-dd HH:mm:ss")); // "2024-06-15 14:30:00"