Getting only time of a datetime object

c#, datetime

Solution

You can use the `ToString` method with the appropriate formatting string:

var time = date.ToString("H:mm");

Problem

I am trying to get only the time of a `DateTime` object. Let's say I have this object: ``` Nullable<DateTime> data = new DateTime(2007,6,15,5 ,23,45); ``` I tryed using : ``` data.Value.ToShortTimeString() ``` And I recieve: ``` 5:23 AM ``` I would like to be able to display only `5:23` How can I do that?

Original source

Related problems