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:
2025-01-18T17:42:46+01:00

 More on Stackoverflow   Read the doc  Random snippet

  Work with me!


Call to action

Did you like this post? You can help me back in several ways: (use the "reply" link on the right to comment or to contact me )

Thank you for reading! And see you soon on Strangebuzz! 😉

COil