How To Append ‘st’, ‘nd’, ‘rd’ or ‘th’ To Day Numbers in Dates

For a new project, my client required to output date strings in a format that included the two letter suffix added to the day number, like in British date (“January 1st 2018” as opposed to “January 1 2018”). The solution makes use of the custom formatting capabilities in the framework whereby it is possible to implement the IFormatProvider and ICustomFormatter interfaces to provide custom string formatting for use with methods that support formatting such as String.Format() or Console.WriteLine(). I decided to extend the existing DateTime format provision in the framework…

Read More