note 11218 deleted from function.putenv by derick
| From: | derick@php.net | Date: | Tue, 13 May 2008 20:34:48 +0000 |
| Subject: | note 11218 deleted from function.putenv by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-139360@lists.php.net to get a copy of this message | ||
Note Submitter: johnhill at webtendon dot com
----
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");