Forum Moderators: coopster
How would this be done with PHP? Is it some calculation based upon GMT? I think (I'll have to check) that the Philippines is +8 GMT...so is that what you'd have to do: create a snippet that grabs the current GMT and add "8" to it?
<?
$offset = 8; // difference to GMT in hours
$phil_time = date("h:i:s A", time() - date("Z") + ($offset * 3600));
echo $phil_time;
?>
# set timezone for dates to New York time
putenv("TZ=America/New_York");
;)
dCrombe's example intrigues me, but how do you show the result?
After you set the time zone (putenv("TZ=America/New_York");) do you use a date function to output the current time in the time zone set?
Also, will the time display update, or do you have to run some sort of loop to get an updated time display?
Last question: I've done some searches on "TZ" on php.net and can't find a listing of timezones to use. Since I want to use a time zone from the Philippines, I'm assuming it would be something like "TZ=Asia/Philippines" but haven't find any documentation to support that assumption.
<?PHP
putenv("TZ=America/New_York");
echo "<P>server timezone set to: ",getenv("TZ"),"<br>\n";
echo date("r"),"</P>\n\n"
?>
<?PHP
putenv("TZ=Asia/Manila");
echo "<P>server timezone set to: ",getenv("TZ"),"<br>\n";
echo date("r"),"</P>\n";
?>
And no, it won't update after the page has loaded because that requires something that executes in the browser, such as JavaScript, and not PHP which runs on the server.
;)
Last question: I've done some searches on "TZ" on php.net and can't find a listing of timezones to use. Since I want to use a time zone from the Philippines, I'm assuming it would be something like "TZ=Asia/Philippines" but haven't find any documentation to support that assumption.
Search your system for "zoneinfo". You'll probably find it in /usr/share. A search on the net for "TZ environment variable" or "zoneinfo" will turn up plenty 'o reading ;)