AM
and PM
values are not easily parsed with TimeSpan.Parse
becuase TimeSpan
technically represents a length of a time interval, not a time of day itself.
You can however use DateTime.Parse
method to parse this value and then retrieve the time part using the TimeOfDay
property as a TimeSpan
:
details.UTCEventDate.Add( DateTime.Parse( details.UTCEventTime ).TimeOfDay );
If you wanted to specify the format even more precisely using ParseExact
, you could use the h:mmtt
format string where tt
represents AM
and PM
part.