php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39261 strftime chops characters with utf-8
Submitted: 2006-10-26 02:16 UTC Modified: 2006-10-26 21:21 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: mehmetyucel at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.1.6 OS: MS Windows 2003 ES/Fedora Core 5
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mehmetyucel at gmail dot com
New email:
PHP Version: OS:

 

 [2006-10-26 02:16 UTC] mehmetyucel at gmail dot com
Description:
------------
If the localization that is set by setlocale has non ISO-8859-1 characters strftime destroys these.
Reproducable on both Fedora Core 5 and Windows 2003 Enterprise Server tested for 2 languages (Spanish / Turkish)

Reproduce code:
---------------
header('Content-Type: text/html; charset=utf-8');

setlocale(LC_TIME,"spanish");
echo strftime("%d %B %Y %A",strtotime("2006-10-28"))."<br>";
setlocale(LC_TIME,"turkish");
echo strftime("%d %B %Y %A",strtotime("2006-10-26"))."<br>";
echo strftime("%d %B %Y %A",strtotime("2006-10-25"))."<br>";


Expected result:
----------------
28 octubre 2006 s?bado
26 Ekim 2006 Per&#351;embe
25 Ekim 2006 ?ar&#351;amba

Actual result:
--------------
28 octubre 2006 s&#6305;do
26 Ekim 2006 Per?r>25 Ekim 2006 &#481;r?r>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-26 09:17 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-10-26 11:42 UTC] mehmetyucel at gmail dot com
5.2 snapshot solved the issue on linux, but problem still exists for windows.

Somehow setlocale sets output encoding of strftime. Following works as a temporary solution for window env.

iconv("ISO-8859-9","UTF-8",strftime("%d %B %Y %A",strtotime("2006-10-26")));
 [2006-10-26 21:21 UTC] derick@php.net
strftime() behaves depending in the OS. As far as I can see it's not even a bug and it's just how Windows handles locales and selects utf8 when it feels like.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 14:01:36 2025 UTC