How do you get the current time of day?

Mitt Rodenbaugh picture Mitt Rodenbaugh · Nov 17, 2008 · Viewed 853.1k times · Source

How do you get the current time (not date AND time)?

Example: 5:42:12 PM

Answer

Mark Brackett picture Mark Brackett · Nov 17, 2008

DateTime.Now.TimeOfDay gives it to you as a TimeSpan (from midnight).

DateTime.Now.ToString("h:mm:ss tt") gives it to you as a string.

DateTime reference: https://msdn.microsoft.com/en-us/library/system.datetime