AM/PM to TimeSpan

前端 未结 4 826
忘了有多久
忘了有多久 2020-12-18 18:55

I want to achieve the converse of this, that is, I want to convert a string with format hh:mm tt to a TimeSpan with zeroed seconds.

4条回答
  •  执念已碎
    2020-12-18 19:41

    TimeSpan tspan;
    
    tspan = DateTime.ParseExact("01:45 PM", "hh:mm tt", CultureInfo.InvariantCulture).TimeOfDay;
    

提交回复
热议问题