Dealing with PHP 5.3 Timezone Errors

From Acenet Knowledgebase
Jump to: navigation, search

PHP 5.3 requires that the timezone setting be set within PHP, and will not use the system timezone settings. The warning that occurs may look similar to the following:

Warning: strftime() [function.strftime]: It is not safe to rely on the system's timezone settings. You are *required* to 
use the date.timezone setting or the date_default_timezone_set() function.

The way to handle this warning is to set the timezone setting in PHP. There are two ways to go about this. Either edit the local php.ini file, or edit the index.php file.

Edit your local php.ini file

Locate the local php.ini file, and add the following line to it:

date.timezone = "America/Detroit"

More details on custom php.ini files can be found here:

How can I change PHP settings?

Edit your index.php file

Add the following line to the index.php file, just under the php tag near the top of the file:

date_default_timezone_set('America/Detroit');

Locating your local TimeZone name

The official name of the local timezone can be found by visiting the following PHP website:

Timezones at php.net