Different Formatter behaviours with the same component configuration

Hi there!

I’m currently facing a problem with the Formatter component.
In my DEV environment, it seems that Yii::$app->formatter has different outputs from my PROD environment, even if the component’s configurations are the same in the application.

With dates:
I’ve detected that Yii::$app->formatter($somedate, 'short') outputs DD/MM/YY in PROD, but in DEV it outputs DD/MM/YYYY.

I was able to workaround this situation using Yii::$app->formatter($somedate, ‘php:d/m/Y’), but I’d like to understand what is going on so to properly fix it.

With negative numbers:
Also, when dealing with negative numbers, in DEV we have -200,00 , whereas in PROD we get the positive number in parenthesis (200,00)

Does anyone have a clue on that? I’m suspecting that it is something related with the PHP configuration itself, but I’m not this advanced to trying something over there.

Thank you for your time.
Kind regards,

Most probably your environments are different, there is no intl library on one of them, or ICU versions are different.

Hey, @Bizley , thank you for the answer.
Yes, I believe you are right. I’m trying to find my way through those. If you have any good content where I can learn from, it would be very welcomed.

I found dealing with server, PHP extensions and all that very risky because I’ve made some booboos in the past :sweat_smile: .

But thanks anyways.

The safest bet with configurations on two environments is to make them absolutely identical, so something like Docker images is handy. Otherwise you need to carefully compare them and try to make them as identical version-wise as possible.

1 Like