Fixing timezones the easy way
- October 25th, 2007
- php
I just ran into some trouble with an interface that is running on a germany based server but is accessed from a server in the U.S. and also in german. So when a client ie opens a ticket it will appear with the german time. An easy way to fix this issue on a linux based system is by setting the timezone environment with putenv.
<?php $us_ip = "<your_server_ip>"; echo "localtime: ".date("H:i:s"); if($_SERVER['SERVER_ADDR'] == $us_ip) { putenv('TZ=US/Central'); } echo " US/Central time: ".date("H:i:s"); ?>(via http://www.php.net/putenv)
















Submit your comment