1

I have a new Symfony 6.4 web application, pretty barebone.

I'm trying to format a date using the Twig format_datetime filter:

{{ post.createdAt ? post.createdAt|format_datetime('c') : '' }}

When calling the page, I get a 500 error

Unknown "format_datetime" filter in post/index.html.twig at line 28.

I do not understand what I'm missing.

1 Answer 1

1

The Twig format_date filter which is related to the format_datetime filter has a note explaining we need to install 2 dependencies to use it:

composer require twig/intl-extra
composer require twig/extra-bundle

After installing it, the filter works fine.

Sign up to request clarification or add additional context in comments.

1 Comment

Unsure why you've made that PR - The exact same note is already present inside the current documentation, as well on the website

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.