There was a problem loading the comments.

How to change timezone in PHP scripts?

Support Portal  »  Knowledgebase  »  Viewing Article

  • 19 June 2009 1:17 PM

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

echo "Original Time: ". date("h:i:s")."\n";
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:

Share via
Did you find this article useful?  

Related Articles


Add Comment

Replying to  

Self-Hosted Help Desk Software by SupportPal