Dates and Times
DateTime, TimeSpan and DateOnly handle dates. Format with ToString.
Example
var d = new DateTime(2026, 3, 15, 10, 30, 0);
Console.WriteLine(d.ToString("yyyy-MM-dd HH:mm"));
Console.WriteLine(d.AddDays(10).DayOfWeek);
Console.WriteLine((new DateTime(2026, 4, 1) - d).Days);Exercise
Add days.
d.(10)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.