How convert TimeSpan to 24 hours and minutes String?

前端 未结 5 927
生来不讨喜
生来不讨喜 2020-12-29 04:09

I use this code for converting Timespan to String (for ex: 14:53) :

myTimeSpan.ToString(\"hh:mm\");

but this erro

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-29 05:04

    You need to use @"hh\:mm\" for TimeSpan. Timespan formatting is not exactly same as DateTime

    myTimeSpan.ToString(@"hh\:mm");
    

    Check out Msdn for more info

提交回复
热议问题