Languages
[Edit]
EN

C# / .NET - get current date and time

5 points
Created by:
Wade
562

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
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
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