How can I String.Format a TimeSpan object with a custom format in .NET?

后端 未结 19 1545
情深已故
情深已故 2020-11-22 12:25

What is the recommended way of formatting TimeSpan objects into a string with a custom format?

19条回答
  •  再見小時候
    2020-11-22 12:44

    This is awesome one:

    string.Format("{0:00}:{1:00}:{2:00}",
                   (int)myTimeSpan.TotalHours,
                   myTimeSpan.Minutes,
                   myTimeSpan.Seconds);
    

提交回复
热议问题