Date Formatting
Format specifier | Description | Examples |
---|---|---|
"d" | Short date pattern. More information:The Short Date ("d") Format Specifier. |
2009-06-15T13:45:30 -> 6/15/2009 (en-US) 2009-06-15T13:45:30 -> 15/06/2009 (fr-FR) 2009-06-15T13:45:30 -> 2009/06/15 (ja-JP) |
"D" | Long date pattern. More information:The Long Date ("D") Format Specifier. |
2009-06-15T13:45:30 -> Monday, June 15, 2009 (en-US) 2009-06-15T13:45:30 -> 15 июня 2009 г. (ru-RU) 2009-06-15T13:45:30 -> Montag, 15. Juni 2009 (de-DE) |
"f" | Full date/time pattern (short time). More information: The Full Date Short Time ("f") Format Specifier. |
2009-06-15T13:45:30 -> Monday, June 15, 2009 1:45 PM (en-US) 2009-06-15T13:45:30 -> den 15 juni 2009 13:45 (sv-SE) 2009-06-15T13:45:30 -> Δευτέρα, 15 Ιουνίου 2009 1:45 μμ (el-GR) |
"F" | Full date/time pattern (long time). More information: The Full Date Long Time ("F") Format Specifier. |
2009-06-15T13:45:30 -> Monday, June 15, 2009 1:45:30 PM (en-US) 2009-06-15T13:45:30 -> den 15 juni 2009 13:45:30 (sv-SE) 2009-06-15T13:45:30 -> Δευτέρα, 15 Ιουνίου 2009 1:45:30 μμ (el-GR) |
"g" | General date/time pattern (short time). More information: The General Date Short Time ("g") Format Specifier. |
2009-06-15T13:45:30 -> 6/15/2009 1:45 PM (en-US) 2009-06-15T13:45:30 -> 15/06/2009 13:45 (es-ES) 2009-06-15T13:45:30 -> 2009/6/15 13:45 (zh-CN) |
"G" | General date/time pattern (long time). More information: The General Date Long Time ("G") Format Specifier. |
2009-06-15T13:45:30 -> 6/15/2009 1:45:30 PM (en-US) 2009-06-15T13:45:30 -> 15/06/2009 13:45:30 (es-ES) 2009-06-15T13:45:30 -> 2009/6/15 13:45:30 (zh-CN) |
"M", "m" | Month/day pattern. More information: The Month ("M", "m") Format Specifier. |
2009-06-15T13:45:30 -> June 15 (en-US) 2009-06-15T13:45:30 -> 15. juni (da-DK) 2009-06-15T13:45:30 -> 15 Juni (id-ID) |
"O", "o" | Round-trip date/time pattern. More information: The Round-trip ("O", "o") Format Specifier. |
DateTime values: 2009-06-15T13:45:30 (DateTimeKind.Local) --> 2009-06-15T13:45:30.0000000-07:00 2009-06-15T13:45:30 (DateTimeKind.Utc) --> 2009-06-15T13:45:30.0000000Z 2009-06-15T13:45:30 (DateTimeKind.Unspecified) --> 2009-06-15T13:45:30.0000000 DateTimeOffset values: 2009-06-15T13:45:30-07:00 --> 2009-06-15T13:45:30.0000000-07:00 |
"R", "r" | RFC1123 pattern. More information: The RFC1123 ("R", "r") Format Specifier. |
2009-06-15T13:45:30 -> Mon, 15 Jun 2009 20:45:30 GMT |
"s" | Sortable date/time pattern. More information: The Sortable ("s") Format Specifier. |
2009-06-15T13:45:30 (DateTimeKind.Local) -> 2009-06-15T13:45:30 2009-06-15T13:45:30 (DateTimeKind.Utc) -> 2009-06-15T13:45:30 |
"t" | Short time pattern. More information: The Short Time ("t") Format Specifier. |
2009-06-15T13:45:30 -> 1:45 PM (en-US) 2009-06-15T13:45:30 -> 13:45 (hr-HR) 2009-06-15T13:45:30 -> 01:45 م (ar-EG) |
"T" | Long time pattern. More information: The Long Time ("T") Format Specifier. |
2009-06-15T13:45:30 -> 1:45:30 PM (en-US) 2009-06-15T13:45:30 -> 13:45:30 (hr-HR) 2009-06-15T13:45:30 -> 01:45:30 م (ar-EG) |
"u" | Universal sortable date/time pattern. More information: The Universal Sortable ("u") Format Specifier. |
With a DateTime value: 2009-06-15T13:45:30 -> 2009-06-15 13:45:30Z With a DateTimeOffset value: 2009-06-15T13:45:30 -> 2009-06-15 20:45:30Z |
"U" | Universal full date/time pattern. More information: The Universal Full ("U") Format Specifier. |
2009-06-15T13:45:30 -> Monday, June 15, 2009 8:45:30 PM (en-US) 2009-06-15T13:45:30 -> den 15 juni 2009 20:45:30 (sv-SE) 2009-06-15T13:45:30 -> Δευτέρα, 15 Ιουνίου 2009 8:45:30 μμ (el-GR) |
"Y", "y" | Year month pattern. More information: The Year Month ("Y") Format Specifier. |
2009-06-15T13:45:30 -> June 2009 (en-US) 2009-06-15T13:45:30 -> juni 2009 (da-DK) 2009-06-15T13:45:30 -> Juni 2009 (id-ID) |
Any other single character | Unknown specifier. | Throws a run-time FormatException. |
Time Formatting
The following table defines the format types used to represent hours.
String | Meaning |
---|---|
h | Hours without leading zeros for single-digit hours (12-hour clock). |
hh | Hours with leading zeros for single-digit hours (12-hour clock). |
H | Hours without leading zeros for single-digit hours (24-hour clock). |
HH | Hours with leading zeros for single-digit hours (24-hour clock). |
The following table defines the format types used to represent minutes.
String | Meaning |
---|---|
m | Minutes without leading zeros for single-digit minutes. |
mm | Minutes with leading zeros for single-digit minutes. |
The following table defines the format types used to represent seconds.
String | Meaning |
---|---|
s | Seconds without leading zeros for single-digit seconds. |
ss | Seconds with leading zeros for single-digit seconds. |
The following table defines the format types used to represent a time marker.
Table 4 String Meaning t One-character time marker string.Note: This format is not recommended for use with certain languages, such as Japanese (Japan). With this format, an application always takes the first character from the time marker string, defined by LOCALE_S1159 (AM) and LOCALE_S2359 (PM). Because of this, the application can create incorrect formatting with the same string used for both AM and PM. tt Multi-character time marker string.