date() function doesn't automatically pick up TZ environment variable.
| From: | John Worsley <jlx@commandprompt.com> | Date: | Wed, 14 May 2003 20:15:11 +0000 |
| Subject: | date() function doesn't automatically pick up TZ environment variable. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-147646@lists.php.net to get a copy of this message | ||
Good day,
I'm experiencing an odd issue with the PHP date() function not using the
appropriate time zone variable unless I explicitly set it in the code. I
am not totally sure it is a bug, because perhaps I am not doing something
in my PHP configuration to make TZ automatically available, but please
read on and alert me to my error if so. :)
I am setting the TZ environment variable from my Apache server
configuration file, and it *is* getting set. I can access it with both
getenv("TZ") and $TZ (when globals are registered On). However, the date()
function ignores it until I do the following:
putenv("TZ=" . getenv("TZ"));
...which seems ludicrous, because doesn't the above just say: "set the
environment variable TZ to the value of the environment variable TZ" ? Or
else, am I missing some means of making TZ automatically set in the PHP
$_ENV array that using getenv() in this way somehow alleviates ?
This workaround works, but it's not really a solution, as I would have to
do it in EVERY PHP script that uses this particular time zone, and at that
point I may as well be setting it by hand. Does anyone have any knowledge
on this problem?
I am using Apache 2.0, with PHP 4.2.2. (I did check the Changelog between
4.2.2 and the most recent release, and I didn't see any mention of this
problem, either specific to date() or TZ.)
Any help would be tremendously appreciated.
Best wishes,
John Worsley.
--
John C Worsley | Lead Programmer / Web Developer, Command Prompt, Inc.
(503) 222-2783 | jlx@commandprompt.com | webmaster@thelinuxreview.com
TheLinuxReview | News for Linux Users | http://www.thelinuxreview.com