Languages
[Edit]
EN

C# / .NET - get current date and time

5 points
Created by:
AnnLen
11500

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

References

  1. Coordinated Universal Time (UTC) - Wikipedia
Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join