How convert TimeSpan to 24 hours and minutes String?

前端 未结 5 916
生来不讨喜
生来不讨喜 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 04:59

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

    Custom TimeSpan Format Strings

    The custom TimeSpan format specifiers do not include placeholder separator symbols, such as the symbols that separate days from hours, hours from minutes, or seconds from fractional seconds. Instead, these symbols must be included in the custom format string as string literals. For example, "dd.hh\:mm" defines a period (.) as the separator between days and hours, and a colon (:) as the separator between hours and minutes.

提交回复
热议问题