How do you get the current time of day?


Question

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

Example: 5:42:12 PM

1
253
2/3/2012 9:24:17 AM

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

377
2/8/2016 1:11:10 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon