EN
C# / .NET - get current date and time
5
points
In C# / .NET DateTime
structure allows to take current date and time.
1. Current date and time example
DateTime now = DateTime.Now;
DateTime date = now.Date;
Console.WriteLine(now.ToString());
Console.WriteLine(date.ToString());
Output:
13.08.2019 21:15:45
13.08.2019 00:00:00
2. Current UTC example
DateTime now = DateTime.UtcNow;
DateTime date = now.Date;
Console.WriteLine(now.ToString());
Console.WriteLine(date.ToString());
Output:
13.08.2019 20:15:46
13.08.2019 00:00:00