Standard DateTime Format Strings Output Examples
The following table illustrates the output created by applying some standard DateTime format strings to a particular date and time. Output was produced using the ToString method.
The Format specifier column indicates the format string, the Culture column indicates the culture associated with the current thread, and the Output column indicates the result of formatting.
The different culture values demonstrate the impact of changing the current culture. The culture can be changed by using the Date/Time control panel in Microsoft Windows, by passing your own DateTimeFormatInfo class as the format provider, or by passing a CultureInfo class set to a different culture. Note that changing the culture does not influence the output produced by the 'r' and 's' formats.
|Format specifier||Current culture||Output|
|D||en-US||Tuesday, April 10, 2001|
|f||en-US||Tuesday, April 10, 2001 3:51 PM|
|f||fr-FR||mardi 10 avril 2001 15:51|
|r||en-US||Tue, 10 Apr 2001 15:51:24 GMT|
|r||zh-SG||Tue, 10 Apr 2001 15:51:24 GMT|
|L||en-UZ||Unrecognized format specifier; a format exception is thrown.|