note 11218 added to putenv
| From: | johnhill at webtendon dot com | Date: | Sat, 10 Feb 2001 18:46:52 +0000 |
| Subject: | note 11218 added to putenv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-10883@lists.php.net to get a copy of this message | ||
Here is an example of using putenv to change the timezone for the current script. You would have to
add a putenv() call to each page in which you wanted to change the timezone. This was posted here
about a year ago...I forgot the author's name. He mentioned to "see the zoneinfo
directory-tree on your System for a list". This is usually /usr/share/zoneinfo or
/usr/lib/zoneinfo. It works in PHP3, not sure about PHP4.
//Set the Timezone
print("server timezone is: " . getenv('TZ') . "<br>\n");
print("server time is: " . date("H:i:s") .
"<br><br>\n");
print("changing server time zone to US/Pacific....<br><br>\n");
putenv("TZ=US/Pacific");
print("new server time is: " . date("H:i:s") . "<br>\n");
print("new server timezone for this script is: " . getenv('TZ'));
some Unix servers may use a different format for TZ. Example: putenv("TZ=PST8EDT");
http://www.php.net/manual/en/function.putenv.php