{ "name": "format_date", "type": "function", "groups": ["String", "Date and Time"], "description": "Formats a date type or string into a custom string format. Uses Qt date/time format strings. See QDateTime::toString.", "arguments": [{ "arg": "datetime", "description": "date, time or datetime value" }, { "arg": "format", "description": "String template used to format the string.
Expression | Output |
---|---|
d | the day as number without a leading zero (1 to 31) |
dd | the day as number with a leading zero (01 to 31) |
ddd | the abbreviated localized day name (e.g. 'Mon' to 'Sun') |
dddd | the long localized day name (e.g. 'Monday' to 'Sunday') |
M | the month as number without a leading zero (1-12) |
MM | the month as number with a leading zero (01-12) |
MMM | the abbreviated localized month name (e.g. 'Jan' to 'Dec') |
MMMM | the long localized month name (e.g. 'January' to 'December') |
yy | the year as two digit number (00-99) |
yyyy | the year as four digit number |
These expressions may be used for the time part of the format string:
Expression | Output |
---|---|
h | the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) |
hh | the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) |
H | the hour without a leading zero (0 to 23, even with AM/PM display) |
HH | the hour with a leading zero (00 to 23, even with AM/PM display) |
m | the minute without a leading zero (0 to 59) |
mm | the minute with a leading zero (00 to 59) |
s | the second without a leading zero (0 to 59) |
ss | the second with a leading zero (00 to 59) |
z | the milliseconds without trailing zeroes (0 to 999) |
zzz | the milliseconds with trailing zeroes (000 to 999) |
AP or A | interpret as an AM/PM time. AP must be either 'AM' or 'PM'. |
ap or a | Interpret as an AM/PM time. ap must be either 'am' or 'pm'. |