Standard Date/Time Format Strings
Created by Brad Overlund (Unlicensed)
Last updated: Nov 13, 2013 by Jessica Rivers (Unlicensed)
A standard Date Time format string consists of a single format specifier character from the following table. If the format string is longer than a single character (even if the extra characters are white spaces), the format string is interpreted as a custom format string. Note that the result string produced by these format specifiers are influenced by the settings in the Regional Options control panel. Computers with different cultures or different date and time settings will generate different result strings.
Character | Description |
---|---|
d | Short date pattern. Displays the short date format based on the current culture (e.g.: en-US culture: M/d/yyyy). |
D | Long date pattern. Displays the long date format based on the current culture (e.g.: en-US culture: dddd, MMMM dd, yyyy). |
t | Short time pattern. Displays the short time format based on the current culture (e.g.: en-US culture: h:mm tt). |
T | Long time pattern. Displays the long time format based on the current culture (e.g.: en-US culture: h:mm:ss tt). |
f | Full date/time pattern (short time). Displays a combination of the long date and short time patterns, separated by a space (e.g.: en-US culture: dddd, MMMM dd, yyyy h:mm tt). |
F | Full date/time pattern (long time). Displays a combination of the long date and long time patterns, separated by a space (e.g.: en-US culture: dddd, MMMM dd, yyyy h:mm:ss tt). |
g | General date/time pattern (short time). Displays a combination of the short date and short time patterns, separated by a space (e.g.: en-US culture: M/d/yyyy h:mm tt). |
G | General date/time pattern (long time). Displays a combination of the short date and long time patterns, separated by a space (e.g.: en-US culture: M/d/yyyy h:mm:ss tt). |
o | Ordinal ("Julian") date pattern. Displays the ordinal date format defined by the custom pattern yyyy-ooo. |
O | Ordinal ("Julian") date pattern. Displays the ordinal date format defined by the custom pattern yyyyooo. |
s | Sort able date/time pattern. Displays a pattern defined by the custom pattern "yyyy-MM-ddTHH:mm:ss" for all cultures. |
M, m | Month, day pattern. Displays month, day format based on the current culture (e.g.: en-US culture: MMMM dd). |
Y, y | Year, month pattern. Displays year, month format based on the current culture (e.g.: en-US culture: MMMM, yyyy). |