Home > Cpanel scripts or addon software installations > Cannot set environment variable ‘TZ’

Cannot set environment variable ‘TZ’

October 6th, 2009

When installing the phpwebsite or php script I face the following error.

Warning: Safe Mode: Cannot set environment variable ‘TZ’ - it’s not in the allowed list in /home/public_html/lib/pear/Date/TimeZone.php on line 251

A: This is caused by the Calendar modules. Calendar uses the Pear Date class which uses a “set environment” command. Some servers do not like to be told how to set their environments. So you will need to turn this off.
Open the file lib/pear/Date/TimeZone.php in a text editor.
Go to line 247. You should be in a function named ‘inDaylightTime()’.
Add this line: return date(”I”);
at the very top of the function.

It should now look like this:

function inDaylightTime($date)
{
return date(”I”);
$env_tz = “”;
if(getenv(”TZ”))
$env_tz = getenv(”TZ”);
putenv(”TZ=”.$this->id);
$ltime = localtime($date->getTime(), true);
putenv(”TZ=”.$env_tz);
return $ltime['tm_isdst'];
}

This should stop the error. Perhaps in the future, the Pear team will supply a work around.

P.S. This can be found in the setup/repair.php file.

Cpanel scripts or addon software installations

  1. No comments yet.
  1. No trackbacks yet.