Date and Time Format Patterns
The following values are available for use in date format patterns:
Symbol | Meaning | Presentation | Examples |
---|---|---|---|
a | AM or PM | Text | PM |
d | Day of month (1-31) | Number | 5, 27 |
dd | Day of month (01-31) | Number | 05, 20 |
D or DD | Day of year (1-366) | Number | 4, 55, 189 |
DD | Day of year (01-366) | Number | 04, 55, 189 |
e | Day of week (1-7, where Monday is 1) | Number | 2 |
E | Day of week, shortened | Text | Tue |
EEEE | Day of week in full | Text | Tuesday |
G | Era | Text | BC, AD |
h | Hour in AM or PM (1-12) | Number | 5 |
hh | Hour in AM or PM (01-12) | Number | 05 |
H | Hour of day in 24 hour format (0-23) | Number | 6 |
HH | Hour of day in 24 hour format (00~23) | Number | 06 |
k | Hour of day in 24 hour format (0-24) | Number | 9 |
kk | Hour of day in 24 hour format (00~24) | Number | 09 |
K | Hour in AM or PM (0-11) | Number | 3 |
KK | Hour in AM or PM (00-11) | Number | 03 |
m | Minute of hour (1-60) | Number | 5 |
mm | Minute of hour (01-60) | Number | 05 |
M | Numeric month (1-12) | Number | 7 |
MM | Numeric month (01-12) | Number | 07 |
MMM | Named month, shortened | Text | JUL |
MMMM | Named month in full | Text | JULY |
s | Seconds of minute (1-60) | Number | 7 |
ss | Seconds of minute (01-60) | Number | 07 |
S | Fraction of second | Number | 978 |
T | Time | Number | 080130, 00:00:00.000 |
w | Week of year | Number | 27 |
x | Weekyear | Year | 1996 |
y | Year | Year | 1996 |
yy | Year | Year | 96 |
yyyy | Year | Year | 1996 |
Y | Year of era (>=0) | Year | 1996 |
YY | Year of era (>=0) | Year | 96 |
YYYY | Year of era (>=0) | Year | 1996 |
Z | Time zone offset/id | Zone | -0800 |
ZZ | Time zone offset/id | Zone | -08:00 |
ZZZ | Time zone offset/id | Zone | America/Los_Angeles |
' | Escape for text | Delimiter | |
'' | Single quote | Literal | ' |
The following formats are not available in Date Time Formats: | |||
C | Century of era (>=0) | Number | 20 |
K | Hour of halfday (0~11) | Number | 3 |
KK | Hour of halfday (0~11) | Number | 03 |
k | Clockhour of day (1~24) | Number | 14 |
kk | Clockhour of day (1~24) | Number | 14 |
The following format is not available for use in toString, which will instead return the same as Z. The time zones supported will be dependent on your server settings. Unsupported time zones will result in an error during analysis. | |||
z | Time zone | Text | PST |
The number of letters used in the pattern determines the format.
- Text: If the number of pattern letters is 4 or more, the full form is used; otherwise a short or abbreviated form is used if available.
- Number: The minimum number of digits. Shorter numbers are zero-padded to this amount.
- Year: Numeric presentation for year and weekyear fields are handled specially. For example, if the count of 'y' is 2, the year will be displayed as the zero-based year of the century, which is two digits.
- Month: 3 or over, use text, otherwise use number.
- Zone: 'Z' outputs offset without a colon, 'ZZ' outputs the offset with a colon, 'ZZZ' or more outputs the zone id.
- Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '?' will appear in the resulting time text even they are not embraced within single quotes.