How do I convert a TimeSpan to a formatted string?

Posted by Michael Wheeler on Stack Overflow See other posts from Stack Overflow or by Michael Wheeler
Published on 2009-05-08T22:18:55Z Indexed on 2010/03/31 11:33 UTC
Read the original article Hit count: 453

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about c#

Related posts about timespan