Format date

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 format 25/12/2022.
  • DATE_MEDIUM: A medium-length version of the date, in the format December 25, 2022.
  • DATE_LONG: A long version of the date, in the format Sunday, December 25, 2022.
  • TIME: The time in the format 12:00:00 PM.
  • TIME_WITHOUT_SECONDS: The time in the format 12:00 PM.
  • HOUR: The hour in the format 12 PM.
  • HOUR_WITHOUT_PADDING: The hour in the format h.
  • MINUTES_AND_SECONDS: The minutes and seconds in the format mm:ss.
  • DAY: The day of the month in the format dd.
  • MONTH: The month as a number in the format mm.
  • MONTH_NAME: The month as a word in the format december.
  • YEAR: The year in the format yyyy.
  • WEEKDAY: The day of the week as a word in the format sunday.
  • DATETIME: The date and time in the format December 25, 2022 at 12:00 PM.
  • DATETIME_MEDIUM: The date and time in the format Sun, Dec 25, 12:00 PM.
  • DATETIME_LONG: The date and time in the format Sunday, 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: Portuguese
  • nl: Dutch
  • en: English
  • de: German
  • ja: Japanese
  • zh: Chinese
  • fr: 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"