php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36642 strftime() randomly do not use setlocale()
Submitted: 2006-03-07 10:35 UTC Modified: 2006-03-07 20:52 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:0 (0.0%)
From: julientld at free dot fr Assigned:
Status: Wont fix Package: Date/time related
PHP Version: 5.1.2 OS: Windows Server 2003 SP1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
46 + 3 = ?
Subscribe to this entry?

 
 [2006-03-07 10:35 UTC] julientld at free dot fr
Description:
------------
Hello,

Finally I decide to submit here a problem that I obtain with PHP from a lot of years. So I have had this problem with PHP 4.x and Windows 2000 (IIS 5.0) and yet with PHP 5.x and Windows Server 2003 (IIS 6.0).

My problem is related to the function strftime() which I use to display dates in my language (French). Sometimes, dates are displayed in French like I want and sometimes dates are displayed in English without any modification of the code. If I refresh the same page 20 times, per exemple, the date will be in English 2 or 3 times and in French the rest of the times. It's very strange and I do not understand why! It just seems to be a bug, no?

For setting the local time, I use setlocale(LC_ALL,"fra"); (I tried also setlocale(LC_ALL,"fr_FR"); and other variants). The function setlocale(LC_ALL,"fra"); is present in an included file which is ever called at the top of the page.

In the release notes of PHP 5.1, I seen that a new parameter in the php.ini has been added to set the time zone (I set it to Europe/Paris). I hoped it's will help me to resolve the problem but not :-(

I seen other persons that have problems with setlocale() and included files. Do you know if it is a PHP bug or a problem in my scripts?
Thanks

Reproduce code:
---------------
echo (strftime("%A %d %B %Y",$timestamp_from_database->date));


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-07 11:05 UTC] derick@php.net
strftime uses locales like you write. Locales are *process-wide* settings, If you're using a threaded server like I suspect you do you can never rely on those settings. strftime() also has nothing to do with the new date code and will not listen to timezone settings. This can not be solved unless we have access to a new database, that doesn't rely on the environment. This will come with ICU's adaption in PHP 6.
 [2006-03-07 16:55 UTC] julientld at free dot fr
Thanks you Derick for your answer. In fact, you want to say that this problem is related to the Microsoft Windows environment and not directly to PHP?

So for the moment, with PHP 5 ans IIS 6.0, the only solution to have dates in French is to create my own function that translate English date's strings.
 [2006-03-07 20:52 UTC] derick@php.net
It's related to having a threaded webserver most likely.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC