Description
The format-date
function takes a single variable as a parameter. It also has several options that can be passed as named parameters. These options allow the user to specify how the date should be formatted when it is returned.
Options
format (mandatory)
The format
option specifies the desired output format for the date. It can be one of the following values:
DATE_SHORT
: A short version of the date, in the format25/12/2022
.DATE_MEDIUM
: A medium-length version of the date, in the formatDecember 25, 2022
.DATE_LONG
: A long version of the date, in the formatSunday, December 25, 2022
.TIME
: The time in the format12:00:00 PM
.TIME_WITHOUT_SECONDS
: The time in the format12:00 PM
.HOUR
: The hour in the format12 PM
.HOUR_WITHOUT_PADDING
: The hour in the formath
.MINUTES_AND_SECONDS
: The minutes and seconds in the formatmm:ss
.DAY
: The day of the month in the formatdd
.MONTH
: The month as a number in the formatmm
.MONTH_NAME
: The month as a word in the formatdecember
.YEAR
: The year in the formatyyyy
.WEEKDAY
: The day of the week as a word in the formatsunday
.DATETIME
: The date and time in the formatDecember 25, 2022 at 12:00 PM
.DATETIME_MEDIUM
: The date and time in the formatSun, Dec 25, 12:00 PM
.DATETIME_LONG
: The date and time in the formatSunday, December 25, 2022 at 12:00 PM
.ISO
: The date and time in ISO 8601 format.TIMESTAMP
: number of miliseconds since 1970 (see https://en.wikipedia.org/wiki/Timestamp)
locale (optional)
The locale
option specifies the desired language for the output. It should be a string representing a locale name.
timezone (optional)
The timezone
option specifies the desired timezone for the output. It should be a string representing a timezone identifier.
inputLocale (optional)
The inputLocale
option specifies the language of the input Date
object. It can be one of the following values:
pt
: Portuguesenl
: Dutchen
: Englishde
: Germanja
: Japanesezh
: Chinesefr
: French
Examples
format-date("2022-12-25", format="DATE_SHORT")
// Outputs "25/12/2022
format-date("2022-12-25", format="DATE_LONG", locale="fr-FR")
// Outputs "Dimanche 25 decembre 2022"