time zone ignored (both via ini or in code)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

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

Good.

[me@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.

Thanks,
Dan

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux