I'm working on a project where I need to format a string with a bunch of stuff but the pertinent part is the first part - the time of a tour:
Given
DateTime start = Convert.ToDateTime(myClass.StartDateTime);
How do I output it with string.Format to show either 10:00 or < space >3:00?
I know I can use a format string like:
string text = string.Format("{0:hh:mm tt}",_start);
but that gives me a leading zero (03:00 PM) that I don't want for single digit hours.
Is there something I can add into the format string to do this or do I have to manually substitute a space for a leading zero? (I suspect this is the case but wanted to ask so I can learn how if there is a format method.)