Been trying to solve this one for hours…
string date = "2009-09-23T13:00:00"
DateTime t = new DateTime();
t = DateTime.ParseExact(date, "HH:mm", null);
Results in this exception:
System.FormatException was unhandled
Message=”String was not recognized as a valid DateTime.”
With ParseExact, you’re trying to take a string and tell the parser exactly what format the string is in. The above line will convert this to a valid DateTime.
If you want to SHOW only the hours and minutes, you would then add the following: