How to Solve Codeigniter Time Zone error
Posted in Codeigniter | 23rd December, 2017
How to Solve Codeigniter Time Zone error:
A PHP Error was encountered
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
If you have not seen this error before in your Codeigniter code but suddenly started showing up, it means that you host may have upgraded to PHP 5.3 or later.
Other people have suggested making the following changes to the index.php:
if( ! ini_get('date.timezone') )
While that may work, I usually do not want to mess with base code.
To solve this problem, a simple solution is to choose your Time Zone example 'America/New_York'
Add the following code to your config.php
Adding this to the Codeigniter configi.php ensures that all parts of your application will sync with this change.
If you are new to Codeigniter, config.php is located at /public_html/application/config