Custom DateTime Format Strings Output Examples

Custom DateTime Format Strings Output Examples

The following table illustrates the output created by applying some custom DateTime format strings to a particular date and time. Output was produced using the ToString method.

The Format specifiers column indicates the format string, the Current culture column indicates the culture associated with the current thread, the Time zone column indicates the time zone in effect when formatting, and the Output column indicates the result of formatting.

The different culture and time zone 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 as the format provider, or by passing a CultureInfo set to a different culture.

Format specifiersCurrent cultureTime zoneOutput
d, Men-USGMT12, 4
d, Mes-MXGMT12, 4
d MMMMen-USGMT12 April
d MMMMes-MXGMT12 Abril
dddd MMMM yy ggen-USGMTThursday April 01 A.D.
dddd MMMM yy gges-MXGMTJueves Abril 01 DC
h , m: sen-USGMT6 , 13: 12
hh:mm, G\MT zen-USGMT05:13 GMT +0
hh:mm, G\MT zen-USGMT +10:0005:13 GMT +10
hh:mm, G\MT zzzen-USGMT05:13 GMT +00:00
hh:mm, G\MT zzzen-USGMT –9:0005:13 GMT -09:00

Note that in some languages such as C#, the '\' character must be preceded by an escape character when used with the ToString method.

See Also

Formatting Overview | Formatting Types | Custom DateTime Format Strings | Standard DateTime Format Strings

© 2015 Microsoft