Date and Time Format Switch
- 2 minutes to read
\@ [ “ ] switch-argument [ “ ]
Word Processing Document API supports the following date and time format codes:
Specifier | Description | Sample Result |
---|---|---|
d | Displays the day as a number, 1 through 31 . | 5 |
dd | Displays the day as a number, 01 through 31 . | 05 |
ddd | Displays the 3-letter day of the week abbreviation according to the current culture. | Fri |
dddd | Displays the full day of the week according to the current culture. | Friday |
M | Displays the month as a number, 1 through 12. | 6 |
MM | Displays the month as a number, 01 through 12. | 06 |
MMM | Displays the 3-letter month abbreviation according to the current culture. | Nov |
MMMM | Displays the full month name according to the current culture. | November |
yy | Displays the 2-digit year. | 20 |
yyyy | Displays 4-digit year. | 2020 |
h | Displays the hour on 12-hour clock, 1 through 12 | 4 |
H | Displays the hour on 12-hour clock, 01 through 12 | 04 |
hh | Displays the hour on 24-hour clock, 0 to 23. | 4 or 20 |
HH | Displays the hour on 24-hour clock, 00 to 23. | 04 or 20 |
m | Displays minutes, 0 to 59. | 8 |
mm | Displays minutes, 00 to 59. | 08 |
am/pm | Displays time using am/pm notation, lowercase. | 04:20 AM |
AM/PM | Displays time using am/pm notation, uppercase. | 04:20 am |
ss | Displays seconds, 01 to 59. | 05 |
Examples:
- Field code {DATE \@ “‘Today is ‘MMM. d, yyyy”} results in Today is Dec. 29, 2011
- Field code {DATE \@ “‘Current time is ‘HH:mm:ss”} results in Current time is 17:13:15