Full Date Short Time ("f") Format Specifier in C#


The Full Date Short Time standard format specifier represents a combination of the long date ("D") and short time ("t") patterns.

UseDateTime to set the date.

DateTime myDate = new DateTime(2018, 8, 29, 1, 10, 0);

Now, use the (“f”) format specifier like this −

myDate.ToString("f", CultureInfo.CreateSpecificCulture("en-US"))

The following is an example −

Example

 Live Demo

using System;
using System.Globalization;
class Demo {
   static void Main() {
      DateTime myDate = new DateTime(2018, 8, 29, 1, 10, 0);
      Console.WriteLine(myDate.ToString("f",CultureInfo.CreateSpecificCulture("en-US")));
   }
}

Output

Wednesday, August 29, 2018 1:10 AM

Updated on: 23-Jun-2020

122 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements