Languages
[Edit]
EN

C# / .NET - get current date and time

5 points
Created by:
AnnLen
9180

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
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join