[c#] How can I get the current time in C#?

I need to get the current time in C# but when I create a DateTime object, the time is set to 00:00:00.

How can I get the current instance of time?

This question is related to c#

The answer is


try this:

 string.Format("{0:HH:mm:ss tt}", DateTime.Now);

for further details you can check it out : How do you get the current time of day?


DateTime.Now is what you're searching for...


DateTime.Now.ToShortTimeString().ToString()

This Will give you DateTime as 10:50PM