6

I'm currently updating my projects to Symfony 5.1 (where I was previously using Symfony 4.1).

When updating I noticed that I can't install the package twig/extensions anymore, which means I can't use the |localizeddate filter.

This has basically already been discussed here: Composer can't install Twig Extensions

- twig/extensions v1.5.0 requires twig/twig ~1.27|~2.0

According to my composer.lock file, 3.0.3 is installed

        ...
        {
            "name": "twig/twig",
            "version": "v3.0.3",
            ...

But just saying something isn't available anymore does not fix the problem


My only use case right now is the following code:

{{ comment.publishedAt|localizeddate('medium', 'short', null, 'UTC') }}

And here is the docs page, for those unfamiliar: https://twig-extensions.readthedocs.io/en/latest/intl.html#localizeddate

Is there another filter or simply another way of how to replace this?

D3strukt0r
  • 571
  • 1
  • 4
  • 19
  • 1
    you also could have copied the code for localizeddate: https://github.com/twigphp/Twig-extensions/blob/master/src/IntlExtension.php – Jakumi Jun 04 '20 at 13:14

1 Answers1

7

The twig/extensions got split up into multiple smaller projects.

So for this case, I had to do

composer require twig/intl-extra

(See: https://github.com/twigphp/intl-extra)

And replace the code with:

{{ comment.publishedAt|format_datetime('medium', 'short', null, 'UTC') }}

(Whether the code works, still has to be tested)

D3strukt0r
  • 571
  • 1
  • 4
  • 19