This documentation is for a version that has reached its End Of Life. Such versions are no longer supported and don't receive security updates. Consider updating to a newer version.
Formatting date and time¶
Using Twig filters and PHP services¶
You can format date and time by using the following services:
@ezplatform.user.settings.short_datetime_format.formatter
@ezplatform.user.settings.short_datet_format.formatter
@ezplatform.user.settings.short_time_format.formatter
@ezplatform.user.settings.full_datetime_format.formatter
@ezplatform.user.settings.full_date_format.formatter
@ezplatform.user.settings.full_time_format.formatter
To use them, create an src\Service\MyService.php
file containing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
Then, add the following to config/services.yaml
:
1 2 3 4 |
|
Using User settings menu¶
Users can set their preferred date and time formats in the User settings menu. This format is used throughout the Back Office.
You can set the list of available formats with the following configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
The default date and time format is set using:
1 2 3 4 5 6 7 8 9 10 |
|
Allowed formats¶
The following subset of the ICU date and time formats is allowed:
Symbol | Meaning |
---|---|
y, yy, yyyy, Y, YY, YYYY | year |
q, Q | quarter |
M, MM, MMM, MMMM, L, LL, LLL, LLLL | month |
w, WW | week |
d, dd | day of the month |
D, DDD | day of the year |
E, EE, EEE, EEEE, EEEEEE, e, ee, eee, eeee, eeeeee, c, cc, ccc, cccc, cccccc | weekday |
a | AM or PM |
h, hh, H, HH, k, kk | hour |
m, mm | minute |
s, ss, S... | second |
Z, ZZ, ZZZ, ZZZZZ | timezone |