SecondsToString
/// <summary> /// Converts the seconds to an hour \ min display string. /// </summary> /// <param name="totalSeconds">The \total seconds.</param> /// <returns>A string in the format x hours y mins.</returns> public static string SecondsToString(this int totalSeconds) { var s = TimeSpan.FromSeconds(totalSeconds); return string.Format("{0} hours {1} mins", (int)s.TotalHours, s.Minutes); }Example:
int seconds = 7863; string display = seconds.SecondsToString(); // 2 hours 11 mins
Description
Converts the number of seconds to a string displaying hours and minutes
Details
- Author: K M Thomas
- Submitted on: 25-3-2016 20:31:34
- Language: C#
- Type: System.Int32
- Views: 1753
Double click on the code to select all.