- 1 Minute to read
- Print
- DarkLight
ecx:formatDate
- 1 Minute to read
- Print
- DarkLight
The function ecx:formatDate formats a date according to the specified pattern. The value returned is a string data type.
Example
The following example takes a given date and time in Central European Time (UTC+01:00), applies a specific date formatting, and changes the time zone to Greenwich Mean Time (UTC+00:00). The final parameter displays the time zone.
${ecx:formatDate(ecm:toDate('2010-03-27 16:12:21', ecm:timeZone('Europe/Warsaw')), 'EEEE, MMMMM d, hh:mm aaa', ecm:timeZone('Europe/London'), 'en', true)}
The output is displayed as Saturday, March 27, 03:12 PM GMT.
Structure
ecx:formatDate(date, string, timezone, String, Boolean)
Parameters
Parameter | Description |
---|---|
date | Target date value to format. If the value used for this parameter is a string data type, it must be converted to a date data type with the function ecm:toDate. |
string | Specifies the date format. A list of possible date patterns is available here: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html. The parameter also recognizes the values 'date', 'shortdate', 'time', 'datetimesec', 'datetime', 'shortdatetime', 'xlsdate', 'xlsdatetime', 'iso8601date' and 'iso8601datetime'. The output format is further refined by the variable localeCode. |
timezone | Specifies the output time zone. |
string | Variable localeCode, applies a country-specific format to the date according to the ISO language code used. |
Boolean | Variable withTimeZone, specifies whether the formatted date includes an abbreviation for the time zone. |