可能重复:结果 How我可以用的String.format自定义格式的TimeSpan对象在.NET?
精确副本时间跨度格式
在这里第一个问题:
我有两个日期时间增值经销商,BEGINTIME和结束时间。我已经通过执行以下操作得到他们的区别是:
时间跨度dateDifference = endTime.Subtract(BEGINTIME);如何我现在可以使用C#返回这个字符串HH小时,毫米分钟,SS秒格式。
如果差异00:06:32.4458750
这应该返回这00小时,06分钟,32秒
感谢您的帮助。
解决方案TimeSpan.ToString()做的伎俩适合你?如果不是,它看起来像页面上的code样本描述了如何做一个时间跨度对象的自定义格式。
Possible Duplicate: How can I String.Format a TimeSpan object with a custom format in .NET?
Exact Duplicate
Timespan formatting
First question here:
I have two DateTime vars, beginTime and endTime. I have gotten the difference of them by doing the following:
TimeSpan dateDifference = endTime.Subtract(beginTime);How can I now return a string of this in hh hrs, mm mins, ss secs format using C#.
If the difference was 00:06:32.4458750
It should return this 00 hrs, 06 mins, 32 secs
Thanks for the help
解决方案Would TimeSpan.ToString() do the trick for you? If not, it looks like the code sample on that page describes how to do custom formatting of a TimeSpan object.
更多推荐
如何将时间跨度转换为格式化字符串?
发布评论