1

I know there are many questions about locale issues in PHP. But I can't find any similar question or answer. I need to output German month names on a website. German locale is installed. Here is the output of locale -a:

# locale -a
C
C.UTF-8
POSIX
de_DE
de_DE.iso88591
de_DE.iso885915@euro
de_DE.utf8
de_DE@euro
deutsch
en_US.utf8
german

Now I just use a little test snippet:

<?php
echo setlocale(LC_ALL, 'de_DE.utf8')."\n";
echo strftime('%B %Y', strtotime('2022-03-20'))."\n";

Here is the correct output from executing it on the command line:

# php test.php
de_DE.utf8
März 2022

Now when I execute the same snippet on the same server with a web browser (file:///x.php) the correct locale will be loaded, but the output is in English:

de_DE.utf8
March 2022

Apache 2.4.38 is used as the web server. The php cli version is 7.2.34 and the php module on apache is php7_module (shared). There must be a difference between the php cli and php apache modules, but I don't know the solution?

Thanks for help!

2
  • From another question: try setting multiple names. Perhaps cli and module use different names for the same locale? Commented Apr 13, 2022 at 12:21
  • Thanks, yes i tried also de_DE, de_DE.UTF-8, de_DE.iso88591. Always the same problem? Commented Apr 13, 2022 at 12:31

1 Answer 1

0

I found the solution. The problem was solved after disabling the Perl module with a2dismod perl. After this the website shows also the correct date format.

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

2 Comments

Thanks for your hint. I just compared the cli and apache php.ini version and I don't find a difference that causes this problem.

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.