65.9K
CodeProject is changing. Read more.
Home

Time in HH:MM:SS format form the second

starIconstarIconstarIconstarIconstarIcon

5.00/5 (7 votes)

Feb 17, 2010

CPOL
viewsIcon

26033

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
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;
}