Use a predefined PHP date format when using the Twig date filter
Published on 2019-08-18 • Modified on 2019-08-18
This is another example where the constant
Twig function can be helpful. In this case we get the \DateTime::ATOM
PHP constant to pass the value to the date
filter. I am using it when generating the dates values of the Atom XML feeds.
{{ 'now'|date(constant('\DateTime::ATOM')) }}
Code execution output:
2024-09-15T11:18:10+02:00
More on Stackoverflow Read the doc Random snippet