Bug #81596 [Opn]: strftime: PHP Apache module ignores locale, while CLI module doesn't.

From: Date: Sat, 06 Nov 2021 18:49:22 +0000
Subject: Bug #81596 [Opn]: strftime: PHP Apache module ignores locale, while CLI module doesn't.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237582@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81596&edit=1

 ID:                 81596
 User updated by:    cmanley at xs4all dot nl
 Reported by:        cmanley at xs4all dot nl
 Summary:            strftime: PHP Apache module ignores locale, while
                     CLI module doesn't.
 Status:             Open
 Type:               Bug
-Package:            Date/time related
+Package:            Apache2 related
 Operating System:   Debian 10.11
 PHP Version:        7.3.32
 Block user comment: N
 Private report:     N

 New Comment:

Other locale aware functions also do not respect the set locale in Apache such as:
printf("%.2f\n", 1000000.123);
which outputs 1000000.12 in Apache and 1000000,12 in the CLI (after setting locale   succesfully to
nl_NL.utf8


Previous Comments:
------------------------------------------------------------------------
[2021-11-06 18:04:15] cmanley at xs4all dot nl

Description:
------------
This is bizar.
Printing the output of strftime('%c') in my preferred locale nl_NL.utf8 returns the
expected output in the CLI version of PHP but in the Apache module it returns an English datetime
string even though setlocale succeeded.

Checks done to exclude noob causes:
- After setting the locale in php, I check that it succeeded with setlocale(LC_TIME, 0) and it
returns my preferred locale.
- The locale exists in the output of "locale -a".
- "sudo pkg-reconfigure locales" done
- Apache restarted
- Machine even restarted.
- The installed CLI and Apache PHP packages are the exact same version.


Test script:
---------------
<?php
ini_set('default_mimetype','text/plain');
print "locale -a:\n" . shell_exec('locale -a') . "\n\n";
date_default_timezone_set('Europe/Amsterdam');
setlocale(LC_TIME, "nl_NL.utf8");
print 'locale after setlocale: ' . setlocale(LC_TIME, 0) . "\n";
print 'php apache ' . phpversion() . ' strftime %c: ' .
strftime("%c\n");
print 'php cli    ' . shell_exec('php -r \'print phpversion();\'') .
' strftime %c: ' . shell_exec('php -r \'setlocale(LC_TIME,
"nl_NL.utf8"); print strftime("%c\\n");\'');


Expected result:
----------------
locale -a:
C
C.UTF-8
POSIX
de_DE
de_DE.iso88591
de_DE.iso885915@euro
de_DE.utf8
de_DE@euro
deutsch
dutch
en_GB
en_GB.iso88591
en_GB.iso885915
en_GB.utf8
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
fr_FR
fr_FR.iso88591
fr_FR.iso885915@euro
fr_FR.utf8
fr_FR@euro
french
german
nl_NL
nl_NL.iso88591
nl_NL.iso885915@euro
nl_NL.utf8
nl_NL@euro


locale after setlocale: nl_NL.utf8
php apache 7.3.31-1~deb10u1 strftime %c: za 06 nov 2021 18:46:33 CET
php cli    7.3.31-1~deb10u1 strftime %c: za 06 nov 2021 18:46:33 CET

Actual result:
--------------
locale -a:
C
C.UTF-8
POSIX
de_DE
de_DE.iso88591
de_DE.iso885915@euro
de_DE.utf8
de_DE@euro
deutsch
dutch
en_GB
en_GB.iso88591
en_GB.iso885915
en_GB.utf8
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
fr_FR
fr_FR.iso88591
fr_FR.iso885915@euro
fr_FR.utf8
fr_FR@euro
french
german
nl_NL
nl_NL.iso88591
nl_NL.iso885915@euro
nl_NL.utf8
nl_NL@euro


locale after setlocale: nl_NL.utf8
php apache 7.3.31-1~deb10u1 strftime %c: Sat Nov  6 18:46:33 2021
php cli    7.3.31-1~deb10u1 strftime %c: za 06 nov 2021 18:46:33 CET


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81596&edit=1


Thread (3 messages)

« previous php.bugs (#237582) next »