date_format()
Usage
date_format(date, pattern)
Description
Formats the given date object according to the given pattern, using the current locale (language/country settings). This method uses the Java SimpleDateFormat class which provides the following pattern chars:
Letter | Date or Time Component |
---|---|
G | Era designator |
y | Year |
Y | Week year |
M | Month in year |
w | Week in year |
W | Week in month |
D | Day in year |
d | Day in month |
F | Day of week in month |
E | Day name in week |
u | Day number of week (1 = Monday, ..., 7 = Sunday) |
a | Am/pm marker |
H | Hour in day (0-23) |
k | Hour in day (1-24) |
K | Hour in am/pm (0-11) |
h | Hour in am/pm (1-12) |
m | Minute in hour |
s | Second in minute |
S | Millisecond |
z | Time zone |
Z | Time zone |
X | Time zone |
Each character can be repeated multiple times to control the output format.
Pattern | Description |
---|---|
d | prints one or two numbers (e.g. "1", "5" or "20") |
dd | prints two numbers (e.g. "01", "05" or "20") |
EEE | prints the shortened name of the weekday (e.g. "Mon") |
EEEE | prints the long name of the weekday (e.g. "Monday") |
Example
${date_format(page.createdDate, 'yyyy-MM-dd')}
results in
2015-12-12