FormatResult
.ToString(“MMMM dd, yyyy”) June 10, 2011
.ToString(“MM/dd/yyyy”)05/09/2019
.ToString(“hh:mmtt”)12:00AM
.ToString(“hh:mm:ss tt”)6:09:01 PM

The “mm” custom format specifier

The “mm” custom format specifier (plus any number of additional “m” specifiers) represents the minute as a number from 00 through 59. The minute represents whole minutes that have passed since the last hour. A single-digit minute is formatted with a leading zero.

The “MM” custom format specifier

The “MM” custom format specifier represents the month as a number from 01 through 12 (or from 1 through 13 for calendars that have 13 months). A single-digit month is formatted with a leading zero.

The “MMM” custom format specifier

The “MMM” custom format specifier represents the abbreviated name of the month. The localized abbreviated name of the month is retrieved from the DateTimeFormatInfo.AbbreviatedMonthNamesproperty of the current or specified culture.

The “MMMM” custom format specifier

The “MMMM” custom format specifier represents the full name of the month. The localized name of the month is retrieved from the DateTimeFormatInfo.MonthNames property of the current or specified culture.

The “tt” custom format specifier

The “tt” custom format specifier (plus any number of additional “t” specifiers) represents the entire AM/PM designator. The appropriate localized designator is retrieved from the DateTimeFormatInfo.AMDesignator or DateTimeFormatInfo.PMDesignator property of the current or specific culture. The AM designator is used for all times from 0:00:00 (midnight) to 11:59:59.999. The PM designator is used for all times from 12:00:00 (noon) to 23:59:59.999.

Make sure to use the “tt” specifier for languages for which it’s necessary to maintain the distinction between AM and PM. An example is Japanese, for which the AM and PM designators differ in the second character instead of the first character.

Sources:

https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

Last modified: July 19, 2019

Author

Comments

Write a Reply or Comment