I’m trying to install a PHP application on my server. But I’m getting this error:
Warning: putenv() [function.putenv]:
Safe Mode warning: Cannot set
environment variable ‘PHP_TZ’ – it’s
not in the allowed list in
…/public/timezone.inc on line 14
I’ve located the offending file and section of code (below). How would I fix this code? What is PHP_TZ supposed to do? Why doesn’t PHP like it? What can I do instead?
//set the timezone
if ($configdata["timezone"] != "") {
putenv("PHP_TZ=" . stripslashes($configdata["timezone"]));
putenv("TZ=" . stripslashes($configdata["timezone"]));
//for >= PHP 5.1
if(function_exists("date_default_timezone_set")) {
date_default_timezone_set($configdata["timezone"]);
}
I’m on PHP 5.2.10. I tried both ‘Europe/Zurich’, and ‘UTC’ for the values for $configdata[“timezone”] and got the same error for both.
PHP_TZ stands for PHP Timezone.
Since the version 5.1 you need to set it through the date_default_timezone_set function or from your PHP configuration. From the documentation :
The easiest fix you could do is the following.