我有一个时间跨度,ts
,主要有分钟和秒,但有时也有几个小时。
我想要ts
返回一个格式化的字符串,该字符串将给出以下结果:
3:30 (hours not displayed, showing only full minutes)
13:30
1:13:30 (shows only full hours instead of 01:13:30)
到目前为止我有:
string TimeSpanText = string.Format("{0:h\\:mm\\:ss}", MyTimeSpan);
但它没有给出上述结果。我怎样才能达到我想要的结果?
也许你想要类似的东西
string TimeSpanText = string.Format(
MyTimeSpan.TotalHours >= 1 ? @"{0:h\:mm\:ss}" : @"{0:mm\:ss}",
MyTimeSpan);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)