Fix Symfony 5 error: during the rendering of a template “Unimplemented date character “Y” in format “MMMM dd Y”

Learn how to easily fix this issue when trying to use a custom date format in Twig.

Unimplemented date character

After a few weeks of using PHP 7.4.8, I moved to PHP 7.4.11 in a Xampp environment, which forced me to install the new version and move all my projects from the old directory to the new directory, however, I didn’t copy the same php.ini config file in the new version because I thought it would work as expected without that much trouble. Well, it doesn’t 😆. When I started the project, I got the following error on the homepage:

An exception has been thrown during the rendering of a template (“Unimplemented date character “Y” in the format “MMMM dd Y”. Please install the “intl” extension for full localization capabilities.”).

This started happening after the implementation of the twig/intl-extra package on the project. How do I fix the error Unimplemented date character? Luckily, the solution is very simple in any environment, because as the bug describes, you just need to install/enable the intl extension for PHP.

PHP in Xampp for Windows

Unimplemented date characterWorkaround: If you’re using PHP in Windows, you’re probably using XAMPP. You can easily fix this error by modifying the default configuration file located in the PHP directory in xampp php.ini:

; c:/xampp/php/php.ini
; Uncomment the intl extension to enable the intl module
extension=intl

After uncommenting the line (just remove the semicolon at the beginning of the line), the module should now be active. You just need to restart the Apache and MySQL services and it will work now:

PHP in Ubuntu

How do I fix the error Unimplemented date character? If you’re working directly on an Ubuntu server, you can install the intl extension in your terminal. First, update the repository:

sudo apt-get update

Then, depending on the PHP version of the server, you can install it using the following command:

# If you are using PHP 5.6
sudo apt-get install php5.6-intl

# If you are using PHP 7.0
sudo apt-get install php7.0-intl

# If you are using PHP 7.4
sudo apt-get install php7.4-intl

After installing the module, don’t forget to restart Apache:

sudo service apache2 restart

In this environment, the problem should also go away.

Happy coding ❤️!