On Mon, Nov 1, 2010 at 12:54 PM, Dan Yost <yod...@gmail.com> wrote:

> 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 (date_default_timezone_get()) {
>    echo 'date_default_timezone_get: ' . date_default_timezone_get() . '<br
> />';
> }
>
> if (ini_get('date.timezone')) {
>    echo 'date.timezone: ' . ini_get('date.timezone');
> }
>
> echo "<Br>";
>
> $localtime = localtime();
> $localtime_assoc = localtime(time(), true);
> print_r($localtime);
> print_r($localtime_assoc);
>
>
> echo "<Br>" . strftime("%D %T %z %Z") . "<br>";
>
> ?>
> ------------
>
>
> 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 +0000 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.
>

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

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

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.

lastly you might see if the calling date_default_timezone_set() does the
trick.

-nathan

Reply via email to