C# DateTime ToShortTimeString
Description
DateTime ToShortTimeString
converts the value of the
current DateTime object to its equivalent short time string representation.
Syntax
DateTime.ToShortTimeString
has the following syntax.
public string ToShortTimeString()
Returns
DateTime.ToShortTimeString
method returns A string that contains the short time string representation of the current
DateTime object.
Example
The following example demonstrates the ToShortTimeString method.
using System;//from w w w . j a va 2 s . c om
class Sample
{
public static void Main()
{
DateTime myDateTime = new System.DateTime(2001, 5, 16, 3, 2, 15);
Console.WriteLine("Long date string: \"{0}\"\n", myDateTime.ToShortTimeString());
}
}
The code above generates the following result.