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

Format
Result
DateTime.Now.ToString(“MM/dd/yyyy”)05/29/2015
DateTime.Now.ToString(“dddd, dd MMMM yyyy”)Friday, 29 May 2015
DateTime.Now.ToString(“dddd, dd MMMM yyyy”)Friday, 29 May 2015 05:50
DateTime.Now.ToString(“dddd, dd MMMM yyyy”)Friday, 29 May 2015 05:50 AM
DateTime.Now.ToString(“dddd, dd MMMM yyyy”)Friday, 29 May 2015 5:50
DateTime.Now.ToString(“dddd, dd MMMM yyyy”)Friday, 29 May 2015 5:50 AM
DateTime.Now.ToString(“dddd, dd MMMM yyyy HH:mm:ss”)Friday, 29 May 2015 05:50:06
DateTime.Now.ToString(“MM/dd/yyyy HH:mm”)05/29/2015 05:50
DateTime.Now.ToString(“MM/dd/yyyy hh:mm tt”)05/29/2015 05:50 AM
DateTime.Now.ToString(“MM/dd/yyyy H:mm”)05/29/2015 5:50
DateTime.Now.ToString(“MM/dd/yyyy h:mm tt”)05/29/2015 5:50 AM
DateTime.Now.ToString(“MM/dd/yyyy HH:mm:ss”)05/29/2015 05:50:06
DateTime.Now.ToString(“MMMM dd”)May 29
DateTime.Now.ToString(“yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss.fffffffK”)2015-05-16T05:50:06.7199222-04:00
DateTime.Now.ToString(“ddd, dd MMM yyy HH’:’mm’:’ss ‘GMT’”)Fri, 16 May 2015 05:50:06 GMT
DateTime.Now.ToString(“yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss”)2015-05-16T05:50:06
DateTime.Now.ToString(“HH:mm”)05:50
DateTime.Now.ToString(“hh:mm tt”)05:50 AM
DateTime.Now.ToString(“H:mm”)5:50
DateTime.Now.ToString(“h:mm tt”)5:50 AM
DateTime.Now.ToString(“HH:mm:ss”)05:50:06
DateTime.Now.ToString(“yyyy MMMM”)2015 May

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

https://www.c-sharpcorner.com/blogs/date-and-time-format-in-c-sharp-programming1

Last modified: November 7, 2021

Author

Comments

Write a Reply or Comment