convert seconds into (Hour:Minutes:Seconds:Milliseconds) / .NET

<= .NET 4.0

TimeSpan t = TimeSpan.FromSeconds( secs );
string answer = string.Format(“{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms”,
t.Hours,
t.Minutes,
t.Seconds,
t.Milliseconds);

NET > 4.0

TimeSpan time = TimeSpan.FromSeconds(seconds);
string str = time .ToString(@”hh\:mm\:ss\:fff”);

http://stackoverflow.com/a/463668

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.