How do I change timezone for PHP?

If you only want particular PHP scripts (and not shell or other cgi scripts) to use a specific timezone, set the timezone environmental variable in your PHP code like so:

PHP Code:
 echo "Original Time: "date("h:i:s")."\n";
         
putenv("TZ=US/Eastern");
         echo 
"New Time: "date("h:i:s")."\n";
?> 


If you put the line putenv("TZ=US/Eastern"); in a file that is
include()'ed by all your other PHP scripts, then all your PHP scripts will use that timezone.

A list of timezones to choose from, other than "US/Eastern" for your putenv() is here:

http://www.theprojects.org/dev/zone.txt

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How do I set PHP include_path?

Use the function ini_set(). For example if you wanted to set your PHP include_path to...

Powered by WHMCompleteSolution