How to set date.timezone for code igniter to work with php5.3

With some versions of PHP you get this error message.

A PHP Error was encountered
Severity: Warning
Message: main(): 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. We selected ‘America/Los_Angeles’ for ‘-8.0/no DST’ instead.

Here is the solution of this error.

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


if( ! ini_get('date.timezone') )
{
   date_default_timezone_set('GMT');
} 

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.