Last night I set up Zend Community Server with PHP 5.3 and gave PyroCMS (running CodeIgniter 1.7.2) a spin. Out of the box v0.9.7.3 and v0.9.8-dev seemed to work fine, except for a single Warning at the top of each page:

“warning: date(): 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. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.”

To fix this, you only need to edit the main index.php for your CodeIgniter application:

`/* |————————————————————— | DEFAULT TIMEZONE |————————————————————— | | Set the default timezone for date/time functions to use if | none is set on the server. | */

if( ! ini_get('date.timezone') )
} `

This modification is something you will probably need to make for any CodeIgniter application running on PHP 5.3 and can easily be modified to your local timezone. There is a full list of supported timezones in the PHP manual here.

Another tweak that might be worth trying (although not something I had an issue with on my apps) will be removing error messages for deprecated functions. I personally would prefer to see these so I know what to fix, but if you are trying to fix an app running on PHP 5.3 quickly, change your error reporting level in index.php like so:

`/* |————————————————————— | PHP ERROR REPORTING LEVEL |————————————————————— | | By default CI runs with error reporting set to ALL. For security | reasons you are encouraged to change this when your site goes live. | For more info visit: | */

error_reporting(E_ALL & ~E_DEPRECATED);`

Have you noticed any other problems when upgrading your CodeIgniter applications to PHP 5.3? If so (and the damn captchas are actually working…) please let me know in the comments.

Blog Logo

Phil Sturgeon

Phil has contributed to CodeIgniter, FuelPHP, Laravel and handfuls of other projects, to try and make the PHP community a better place.


Build APIs You Won't Hate

Everyone and their dog wants an API, so you should probably learn how to build them.

Buy it from LeanPub for $26.99

Published 01 Feb 2014


Phil Sturgeon

Founder of PyroCMS, Senior Developer at Ride, Programming Polyglot, PHP-FIG member, and occasionally gets chased by bears

Back to Overview