Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Time in HH:MM:SS format form the second

0.00/5 (No votes)
16 Feb 2010 1  
Following is code by which you get time in (HH:SS:MM) formate by passing second as argument public string getFormattedTimeFromSecond(double second) { TimeSpan t = TimeSpan.FromSeconds(second); string formatedTime = string.Format({0:D2}H:{1:D2}M:{2:D2}S, ...
Following is code by which you get time in (HH:SS:MM) formate by passing second as argument

C#
public string getFormattedTimeFromSecond(double second)
    {

        TimeSpan t = TimeSpan.FromSeconds(second);

        string formatedTime = string.Format("{0:D2}H:{1:D2}M:{2:D2}S",
                                t.Hours,
                                t.Minutes,
                                t.Seconds);

        return formatedTime;
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here