Re: date() function doesn't automatically pick up TZ environment variable.
| From: | Rasmus Lerdorf | Date: | Wed, 14 May 2003 20:31:22 +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-147647@lists.php.net to get a copy of this message | ||
On Wed, 14 May 2003, John Worsley <jlx@commandprompt.com> wrote:
> 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:
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.
> 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.
-Rasmus