Re: date() function doesn't automatically pick up TZ environment variable.
| From: | John Worsley <jlx@commandprompt.com> | Date: | Wed, 14 May 2003 20:30:30 +0000 |
| Subject: | Re: date() function doesn't automatically pick up TZ environment variable. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147648@lists.php.net to get a copy of this message | ||
On Wed, 14 May 2003, Rasmus Lerdorf wrote:
>Setting it in your Apache environment doesn't help. It has to be set in
>the Unix environment, so the script that starts your Apache server needs
>to do a real setenv before starting Apache. Apache env variables you
>define in your configuration file are available from PHP via getenv(), but
>that doesn't mean they are in the underlying Unix env.
Ahh. Of course the problem there is that doing so would be a global
change, rather than a change specific to the host. :/ Different hosts
require different time zone settings.
>>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 ?
>Nope, getenv() checks the server env first, then the unix environment. In
>your case you have it set only in your server environmennt. putenv()
>explicitly sets it in the unix env.
Ah, I see. I don't suppose anyone knows of a way to do what I am
attempting? :) Specifically, transparently setting the TZ for a virtual
host within Apache so that PHP would pick it up automatically? I suppose
the real rub here is that PHP doesn't look to the results of getenv(TZ)
for its time zone setting.
If not, I suppose the only thing I can do is to set the TZ value by hand
in each of the application files (or in a common include, or some such
thing).
Best Wishes, and many thanks for the reply,
Jw.
--
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