ID: 22135
User updated by: vaughan at ucla dot edu
Reported By: vaughan at ucla dot edu
Status: Open
Bug Type: Date/time related
Operating System: Linux (debian)
PHP Version: 4.2.3
New Comment:
You're right. I should have used "America/Los_Angeles".
results: experiment #1, using
putenv("TZ=America/Los_Angeles");
php produces the correct time after this, but not before (that is,
doesn't pick up TZ from the system).
experiment # 3, SetEnv TZ=America/Los_Angeles in httpd.conf
has no effect -- the time is still wrong until I use putenv with either
"US/Pacific" or "America/Los_Angeles".
Previous Comments:
------------------------------------------------------------------------
[2003-02-22 13:37:46] michael dot mauch at gmx dot de
I don't see a /usr/share/zoneinfo/US/Los_Angeles on Debian, only
America/Los_Angeles (and US/Pacific). So I suggest you try again with
America/Los_Angeles.
------------------------------------------------------------------------
[2003-02-22 11:37:58] vaughan at ucla dot edu
no, TZ is not being set in httpd.conf nor in apachectl.
Experiment #1
What happens if we use putenv("TZ=US/Los_Angeles")?
the script:
<?
print("server timezone is: " . getenv('TZ') . "<br>\n");
print("server time is: " . date("F j, Y, g:i a") . "<br>\n");
print("changing server time zone to US/Los_Angeles....<br>\n");
putenv("TZ=US/Los_Angeles");
print("new server time is: " . date("F j, Y, g:i a") . "<br>\n");
print("new server timezone for this script is: " . getenv('TZ'));
?>
here's the output, with the incorrect times:
server timezone is: America/Los Angeles
server time is: February 22, 2003, 5:01 pm
changing server time zone to US/Los_Angeles....
new server time is: February 22, 2003, 5:01 pm
new server timezone for this script is: US/Los_Angeles
output of date(T):US/Los_Angeles
Experiment # 2:
I also tried putting
SetEnv US/Pacific
into httpd.conf.
this script:
print("server timezone is: " . getenv('TZ') . "<br>\n");
print("server time is: " . date("F j, Y, g:i a") . "<br>\n");
print("changing server time zone to US/Pacific....<br>\n");
putenv("TZ=US/Pacific");
print("new server time is: " . date("F j, Y, g:i a") . "<br>\n");
print("new server timezone for this script is: " . getenv('TZ'));
produces this output:
server timezone is: US/Pacific
server time is: February 22, 2003, 5:29 pm
changing server time zone to US/Pacific....
new server time is: February 22, 2003, 9:29 am
new server timezone for this script is: US/Pacific
output of date(T):PST
In this case, PHP picks up the US/Pacific timezone from the
environment, but gets the time wrong!
Experiment # 3
try with SetEnv = US/Los_Angeles in httpd.conf
same script as #2, produces bad output:
server timezone is: US/Los_Angeles
server time is: February 22, 2003, 5:34 pm
changing server time zone to US/Pacific....
new server time is: February 22, 2003, 9:34 am
new server timezone for this script is: US/Los_Angeles
output of date(T):PST
So it seems to be the case that the ONLY way to get PHP to have the
correct time is to use putenv("TZ=US/Pacific") in a script.
Any other ideas? Thanks for your help
------------------------------------------------------------------------
[2003-02-09 16:49:25] michael dot mauch at gmx dot de
You don't have a
SetEnv TZ "America/Los Angeles"
in your httpd.conf, do you? Or maybe TZ is fixed in your apachectl
script?
------------------------------------------------------------------------
[2003-02-09 13:54:50] vaughan at ucla dot edu
here's what I do, as root:
# export TZ='America/Los_Angeles'
# set | grep TZ
# TZ=America/Los_Angeles
# apachectl stop
/usr/sbin/apachectl stop: httpd stopped
# apachectl start
/usr/sbin/apachectl start: httpd started
output of the php script:
server timezone is: America/Los Angeles
server time is: February 9, 2003, 7:51 pm
changing server time zone to US/Pacific....
new server time is: February 9, 2003, 11:51 am
new server timezone for this script is: US/Pacific
I notice that PHP does not pick up the underscore in "Los_Angeles".
What I wondered was whether there's a way to do the equivalent of
putenv("TZ=US/Pacific") in php.ini?
However, I have just noticed that the time is wrong in OTRS running on
the same server -- and it is a set of perl scripts. So maybe this is
not a PHP bug at all?
------------------------------------------------------------------------
[2003-02-09 12:39:25] michael dot mauch at gmx dot de
"apachectl restart" does not pick up the new TZ environment variable.
Did you try apachectl stop / apachectl start? I get the same results as
you with TZ="America/Los Angeles", but "America/Los_Angeles" or
"US/Pacific" work. As far as I know there's no php.ini setting that
fiddles with timezones.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/22135
--
Edit this bug report at http://bugs.php.net/?id=22135&edit=1