{ "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.
ExpressionOutput
dthe day as number without a leading zero (1 to 31)
ddthe day as number with a leading zero (01 to 31)
dddthe abbreviated localized day name (e.g. 'Mon' to 'Sun')
ddddthe long localized day name (e.g. 'Monday' to 'Sunday')
Mthe month as number without a leading zero (1-12)
MMthe month as number with a leading zero (01-12)
MMMthe abbreviated localized month name (e.g. 'Jan' to 'Dec')
MMMMthe long localized month name (e.g. 'January' to 'December')
yythe year as two digit number (00-99)
yyyythe year as four digit number

These expressions may be used for the time part of the format string:

ExpressionOutput
hthe hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
hhthe hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
Hthe hour without a leading zero (0 to 23, even with AM/PM display)
HHthe hour with a leading zero (00 to 23, even with AM/PM display)
mthe minute without a leading zero (0 to 59)
mmthe minute with a leading zero (00 to 59)
sthe second without a leading zero (0 to 59)
ssthe second with a leading zero (00 to 59)
zthe milliseconds without trailing zeroes (0 to 999)
zzzthe milliseconds with trailing zeroes (000 to 999)
AP or Ainterpret as an AM/PM time. AP must be either 'AM' or 'PM'.
ap or aInterpret as an AM/PM time. ap must be either 'am' or 'pm'.
" }, { "arg": "language", "optional": true, "description": "language (lowercase, two- or three-letter, ISO 639 language code) used to format the date into a custom string. By default the current QGIS user locale is used." }], "examples": [{ "expression": "format_date('2012-05-15','dd.MM.yyyy')", "returns": "'15.05.2012'" }, { "expression": "format_date('2012-05-15','d MMMM yyyy','fr')", "returns": "'15 mai 2012'" }, { "expression": "format_date('2012-05-15','dddd')", "returns": "'Tuesday', if the current locale is an English variant" }, { "expression": "format_date('2012-05-15 13:54:20','dd.MM.yy')", "returns": "'15.05.12'" }, { "expression": "format_date('13:54:20','hh:mm AP')", "returns": "'01:54 PM'" }], "tags": ["custom", "type", "uses", "format", "strings", "time", "date", "formats", "see", "qdatetime", "tostring"] }