Short Time 't' Format Specifier in C#



The Short Time format specifier represents a custom date and time format string.

It is defined by the current DateTimeFormatInfo.ShortTimePattern property.

For example, the custom format string is −

HH:mm

Example

 Live Demo

using System;
using System.Globalization;
class Demo {
   static void Main() {
      DateTime date = new DateTime(2018, 5, 4, 10, 12, 10);
      Console.WriteLine(date.ToString("t", CultureInfo.CreateSpecificCulture("en-us")));
   }
}

Output

10:12 AM
Updated on: 2020-06-23T07:03:57+05:30

433 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements