[PHP] time zone ignored (both via ini or in code)

2010-11-01 Thread Dan Yost
Greetings,

I've looked through a number of different archived threads (some
rather heated) and samples as well, but clearly I'm just missing
something.

PHP 5.1.6
CentOS release 5.5 (Final)

My server is in Central Time (US). We do observe DST. I noticed
functions like strftime() display UTC time. So I undertook fixing
this.

I read several threads about setting date.timezone in php.ini, and
arguments for/against different timezone methods. But in my case I see
no reason why setting the timezone in php.ini would hurt us--we can
live with that. And yet:

[...@ez2 html 13:47:20]$ date
Mon Nov  1 13:50:05 CDT 2010

Good.

[...@ez2 html 13:50:05]$ grep -i timezone /etc/php.ini
date.timezone = "America/Chicago"

Good--and yes, Apache was restarted. So far, we're Central, life is good.

Let's hit PHP now:


';
}

if (ini_get('date.timezone')) {
echo 'date.timezone: ' . ini_get('date.timezone');
}

echo "";

$localtime = localtime();
$localtime_assoc = localtime(time(), true);
print_r($localtime);
print_r($localtime_assoc);


echo "" . strftime("%D %T %z %Z") . "";

?>



Which produces:


date_default_timezone_get: America/Chicago
date.timezone: America/Chicago
Array ( [0] => 14 [1] => 51 [2] => 18 [3] => 1 [4] => 10 [5] => 110
[6] => 1 [7] => 304 [8] => 0 ) Array ( [tm_sec] => 14 [tm_min] => 51
[tm_hour] => 18 [tm_mday] => 1 [tm_mon] => 10 [tm_year] => 110
[tm_wday] => 1 [tm_yday] => 304 [tm_isdst] => 0 )
11/01/10 18:51:14 + UTC


Timezone is America/Chicago, yet date functions completely ignore this
and continue to display UTC.

Please help me understand where I'm blind here.

Thanks,
Dan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] time zone ignored (both via ini or in code)

2010-11-02 Thread Dan Yost
On Tue, Nov 2, 2010 at 12:29 AM, Nathan Nobbe  wrote:
> a few thoughts,
> 1. set error_reporting to E_ALL to see if the engine is trying to tell you
> something you may be overlooking


Sorry, failed to mention that I did this, and it says nothing.


> 2. for grins, maybe see if the TZ environment variable is set on your system
>     var_dump(getenv('TZ'));


I didn't post the phpinfo() output originally but had checked and no,
TZ isn't set.


> 3. another test would be to set date.timezone to something else and see if
> date_default_timezone_get() returns that new value, which would indicate
> it's falling through to the third option in the precedence chain.


AHA!

I had tried checking validity by setting a BOGUS time zone (which
showed that it was taking effect), but I had not tried checking by
setting an alternate VALID time zone.

Guess what? It works. If I set it to America/Denver, I get correct output.

Thus, something is corrupt in the timezone DB itself (which I believe
is internal to PHP from what I understand from the threads I've read).

America/Chicago is completely broken but America/Denver works just fine.

Incidentally, I have noticed that CentOS is completely broken in their
tz distro. Every time it updates, it includes a US/Central file that
is completely invalid. This has persisted for months--at the OS level
I've fixed it by copying in a valid US/Central file from another box.
But doing that does not fix PHP (tried that just now)--which again I'd
expect it not to anyway, since I believe PHP (as of PHP5) has an
internal timezone DB. But I tried it just in case.

So now I suppose the thread becomes: how do I get a valid US/Central
(America/Chicago) timezone in PHP5?

Thanks much,
Dan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] time zone ignored (both via ini or in code)

2010-11-02 Thread Dan Yost
On Tue, Nov 2, 2010 at 9:19 AM, Nathan Nobbe  wrote:
> On Tue, Nov 2, 2010 at 7:52 AM, Dan Yost  wrote:
>>
>> So now I suppose the thread becomes: how do I get a valid US/Central
>> (America/Chicago) timezone in PHP5?
>
> give the timezonedb extension a shot
> http://pecl.php.net/package/timezonedb


Tried it, no change. It is still impossible to get simple CENTRAL
timezone output. This is maddening.

Dan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] time zone ignored (both via ini or in code)

2010-11-02 Thread Dan Yost
On Tue, Nov 2, 2010 at 11:02 AM, Nathan Nobbe  wrote:
>> >>
>> >> So now I suppose the thread becomes: how do I get a valid US/Central
>> >> (America/Chicago) timezone in PHP5?
>> >
>> > give the timezonedb extension a shot
>> > http://pecl.php.net/package/timezonedb
>>
>>
>> Tried it, no change. It is still impossible to get simple CENTRAL
>> timezone output. This is maddening.
>
> That's really weird since I'm sure php has its own timezone db, and it
> sounds like that's where PHP is getting it if you saw the correct output
> after switching date.timezone to America/Denver.  What about trying
> date_default_timezone_set() ?


I had tried that originally too. It does set the timezone "correctly,"
but then again so does the ini set. So the timezone does get set to
America/Chicago with a date_default_timezone_set(), and then PHP
shanks from there, showing UTC. It seems certain that the timezone
*does* get set to America/Chicago (via multiple methods), and that
America/Chicago *itself* is corrupt in PHP--and that's even with
timezonedb installed. Now everybody knows Chicago is full of
corruption, but at least the clocks aren't, right?

Surely there are bizillions of others out there running this
combination of software in the Central time zone! Yet it's as if
nobody else has corrupt timezone DB records (be they internal or via
timezonedb) except me. And I can't help but notice how CentOS (tzdata
package) is also corrupt, every single time it gets updated, on the
Central zone but no others. Obviously these should be entirely
separate issues, but "somebody" out there has it out for the Central
time zone. Probably a Yankees fan.

Dan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] time zone ignored (both via ini or in code)

2010-11-02 Thread Dan Yost
On Tue, Nov 2, 2010 at 11:37 AM, Nathan Nobbe  wrote:

> dude at this point i dont want to sound too much like a troll, but php 5.1
> is some really old software.  frankly this is why i chose not to run on
> centos during my evaluation of it.  i understand the concept behind running
> proven stable software, but i think centos is taking that notion to the
> extreme.  i would probly try building a more recent version of php from
> source and see if that helps.


That's OK, I knew this was coming. It's been a real struggle to be
deploying something so old, yet CentOS insists on nothing but 5.1 in
the packages unless you resort to some "volatile" repositories, which
kind of defeats the purpose (in my case, that is). I used to always go
with source directly but was really hoping to go the
somewhat-brainless "auto-update" route, sticking to yum packages and
all that.

At risk of sending this thread too far down an OS-specific path, can
anybody in the CentOS+PHP world comment on yum packages, 5.1, and this
actual issue?

(In the very beginning I scoured the Net, thinking surely 5.1.6 can't
be the standard on CentOS, but kept running into the "either go from
source yourself or use volatile repositories" claims, which aren't
good in an enterprise case, though I realize using source isn't "bad"
from that standpoint).

Dan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php