.NET API Browser

DateTimeFormatInfo Class

The DateTimeFormatInfo class provides culture-specific information about the format of date and time values. It is used by the DateTime and TimeSpan parsing and formatting methods.

Properties

public string ShortDatePattern { get; set; }

Gets or sets the format pattern for a short date value.

public string LongDatePattern { get; set; }

Gets or sets the format pattern for a long date value.

public string ShortTimePattern { get; set; }

Gets or sets the format pattern for a short time value.

public string LongTimePattern { get; set; }

Gets or sets the format pattern for a long time value.

Methods

public string GetMonthName(int month)

Returns the culture-specific name of the specified month.

public string GetAbbreviatedMonthName(int month)

Returns the abbreviated name of the specified month.

public string GetDayName(DayOfWeek dayOfWeek)

Returns the culture-specific culture name of the specified day of the week.

Example

using System;
using System.Globalization;

class Program
{
    static void Main()
    {
        var dtfi = CultureInfo.GetCultureInfo("en-US").DateTimeFormat;
        dtfi.ShortDatePattern = "yyyy-MM-dd";
        dtfi.ShortTimePattern = "HH:mm";

        DateTime now = DateTime.Now;
        Console.WriteLine(now.ToString("d", dtfi)); // 2025-09-10
        Console.WriteLine(now.ToString("t", dtfi)); // 14:23
        Console.WriteLine(dtfi.GetMonthName(12));   // December
    }
}

See Also