Format date and time¶
Twig filters¶
Apart from changing the date and time formats, you can use Twig filters:
ez_short_datetime
ez_short_date
ez_short_time
ez_full_datetime
ez_full_date
ez_full_time
The following are examples of using the filters:
1 2 3 4 5 6 7 |
|
The filters accept an optional timezone
parameter for displaying date and time in a chosen time zone.
The default time zone is set in the User settings menu.
For details, see reference materials on the full format filters and short format filters.
Services¶
You can also 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 |
|