TimeSpan format: h(hour) and m(minutes) : TimeSpan Format « Date Time « C# / C Sharp






TimeSpan format: h(hour) and m(minutes)

   

using System;

public class Example
{
   public static void Main()
   {

        TimeSpan ts = new TimeSpan(3, 42, 0);
        Console.WriteLine("{0:%h} hours {0:%m} minutes", ts);
   }
}
//3 hours 42 minutes

   
    
    
  








Related examples in the same category

1.TimeSpan format: %d
2.TimeSpan format: d\.hh\:mm\:ss
3.TimeSpan format: d\.hh\:mm\:ss for new TimeSpan(3, 4, 3, 17)
4.Indicate format for TimeSpan parse
5.Standard TimeSpan Format String: c
6.Standard TimeSpan format: g
7.Standard TimeSpan format: G (2)
8.Converts TimeSpan to string with ToString() using the specified format: "c", "g", "G"
9.Converts TimeSpan to string using the specified format and culture-specific formatting information.
10.Converts TimeSpan to string with default ToString
11.TimeSpan Format with Flag
12.Convert To TimeSpan