|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39993 tr_TR.UTF-8 locale has problems with PHP
Submitted: 2006-12-30 18:22 UTC Modified: 2007-01-18 23:20 UTC
From: tunix at raptiye dot org Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.0 OS: Arch Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: tunix at raptiye dot org
New email:
PHP Version: OS:


 [2006-12-30 18:22 UTC] tunix at raptiye dot org
I type

<?php echo date("l"); ?>

into an empty php file and then run it in command line prompt, and it prints this error message:

Fatal error: date(): Timezone database is corrupt - this should *never* happen! in Command line code on line 1

If I use tr_TR.UTF-8 locale, then I can produce this error. But if I use tr_TR.ISO8859-9 or C locales, it doesn't print the error message. Although, tr_TR.ISO8859-9 and C locales return Saturday which is English. It should return "Cumartesi" (turkish).

GNU date command works fine with UTF-8 locale.

[19:07] (tunix@penguix ~)$ TZ=Europe/Istanbul LANG=tr_TR.UTF-8 date +%A

Reproduce code:
[19:06] (tunix@penguix ~)$ TZ=Europe/Istanbul LANG=tr_TR.UTF-8 php -r ?date(?l?);?

Fatal error: date(): Timezone database is corrupt - this should *never* happen! in Command line code on line 1

Expected result:
It's supposed to be:

[19:06] (tunix@penguix ~)$ TZ=Europe/Istanbul LANG=tr_TR.UTF-8 php -r ?date(?l?);?



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-30 20:46 UTC]
Please try using this CVS snapshot:
For Windows:
 [2006-12-30 23:08 UTC]
Its is reproducible with the snapshot.
I believe this happens because of strcasecmp() (used in seek_to_tz_position()) behaving weird with tr_TR locale (I remember some similar problems in the past), using something like tolower() & memcmp() should do the trick.
 [2006-12-30 23:45 UTC]
Another option that is a bit more performance friendly is 
something like this:
 [2007-01-01 13:38 UTC] tokul at users dot sourceforge dot net
Issue is not fixed in 5.2.x snapshots (200701011130). You are using locale dependent case insensitive lookups and assume locale independent case sensitivity rules. In Turkish locale 'latin small i' is not same thing as 'latin capital i'. Turks have different case sensitivity rules.

Reproduce code
(TZ='Europe/Helsinki' /usr/bin/php /path/test-locale.php):

Expected result:
string(11) "tr_TR.UTF-8"
string(15) "Europe/Helsinki"
string(11) "tr_TR.UTF-8"
Second line depends on default timezone setting. Make sure that you have 'i' symbol in timezone name.

Actual result (PHP 5.2.0-8 debian and PHP 5.2.1RC2-dev snapshot):
string(11) "tr_TR.UTF-8"

Fatal error: date_default_timezone_get(): Timezone database is corrupt - this should *never* happen! in /path/test-locale.php on line 3

Patch by is not correct, because it does not preserve existing LC_CTYPE value and makes all strtolower/strtoupper calls locale independent when PHP manual states that these calls are locale dependent.

Result after Iliaa's patch is applied:
string(11) "tr_TR.UTF-8"
string(15) "Europe/Helsinki"
string(1) "C"
 [2007-01-18 23:20 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Sep 26 02:01:24 2023 UTC