Reputation:
I have DateTime variable, and I need to get ONLY the time value from that variable.
How can I do that in C#?
Thanks,
Upvotes: 4
Views: 7627
Reputation: 4949
Alternatively you can also use the string formatting for getting the output nicely
string.Format("{0: hh:mm:ss}", DateTime.Now)
Upvotes: 4
Reputation: 21704
If you need string representation of time you can use:
dt.ToShortTimeString()
dt.ToLongTimeString()
Upvotes: 2