Timezone for PHP scripts


September 24th, 2008

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:


<?
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 your all PHP scripts will use that timezone.

This article is released by SupportFacility.Com — the leaders in providing outsourced technical support, live chat support & help desk support for web hosts. Interested ? Opt for a trial now.


No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment