|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-08-13 16:51 UTC] kulakov74 at yandex dot ru
Description:
------------
I tried putenv('TZ=...') to get local time for any timezone. After that, if I don't call putenv('TZ=...') using date/time functions (date()) in consequent requests randomly return either local time or the time for the zone last set with TZ. In Apache access_log's time offsets also vary. It seems that Apache proccesses remember the time for the timezone set with TZ and use it for consequent requests.
Unfortunately, there's no function for deleting an environment variable. Even though with consequent requests TZ seems to be undefined, date functions work as if it were set for the last value.
For a reason, calling mktime(0,0,0,1,1,1970) clears Apache's processes internal time, but that happens only on subsequent requests, not within the same one.
Of course, one can use putenv('TZ=...') for setting local timezone back after working with a different timezone, but anyway I guess that shouldn't be the way it is.
We use Apache 2.
Reproduce code:
---------------
//first request:
echo(date('H:i:s').'<BR>'); //localtime
putenv('TZ=Europe/Moscow');
echo(date('H:i:s').'<BR>'); //Moscow time - works okay
//at consequent requests:
echo(date('H:i:s').'<BR>'); //may produce local or Moscow time, depending on which Apache process handles the request
Expected result:
----------------
see above
Actual result:
--------------
see above
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 15:00:02 2025 UTC |
Though this is an old issue, I had to revisit it, and I found: 1. I can delete an env. var. by putenv('TZ') - a user comment explains that, but the docs does not 2. I cannot reproduce the problem any more - even if I leave the wrong timezone it never shows in consequent requests. Note that the version is 4.1.2. Perhaps something has changed in PHP but I can't test it!