简体   繁体   中英

PHP error_log not respecting the timezone setting?

Timezone problem in error_log?

If I explicitly set the error_log directive to a file in php, and then use the error_log statement with a timezone, then why does it not respect my timezone? See below:

[soham@soham.dev ~]$ cat errlog.php
<?php

date_default_timezone_set('America/Los_Angeles');
ini_set('error_log', '/tmp/blah');
ini_set('display_errors', 'on');
error_log('whatever');
?>

[soham@soham.dev ~]$ php errlog.php

[soham@soham.dev ~]$ cat /tmp/blah
[12-Aug-2010 02:16:29] whatever

[soham@soham.dev ~]$ date
Wed Aug 11 19:16:34 PDT 2010

[soham@soham.dev ~]$

The closest thing I can find is http://bugs.php.net/45191 , but that is fixed in 5.2.10. But I'm running 5.2.11:

[soham@soham.dev ~]$ php -v
PHP 5.2.11 (cli) (built: Apr 17 2010 16:25:19)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
[soham@soham.dev ~]$

Relevant INI settings (which are being over-riden in the code):

[soham@soham.dev ~]$ php -i | grep date.timezone
date.timezone => America/Los_Angeles => America/Los_Angeles

[soham@soham.dev ~]$ php -i | grep error_log
error_log => no value => no value

What am I missing? Any clues appreciated. Thanks.

Upgrading to php5.3.3 fixed this. Have not tried versions in-between (ie between 5.2.11 and 5.3.3).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM