Business Websites, Ecommerce solution, Process Automation!

How to Solve Codeigniter Time Zone error

  Posted in Codeigniter | 23rd December, 2017

Tags.

How to Solve Codeigniter Time Zone error:

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

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') )

{

   date_default_timezone_set('GMT');

}

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

date_default_timezone_set('America/New_York');

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

Post a comment


You can use the following HTML tags: <a><br><strong><b><em><i><blockquote><code><ul><ol><li><del>


CAPTCHA Image
Reload Image

01

Build YourWebsites

>>
Showcase your business online! Whether you need a website for your associations,business, ecommerce or affiliate marketing Call us Now
02

MaintainWeb Assets

Maintain Your Web Assets To ensure optimal performance and 99.9% uptime.We help you fix issues,on-page SEO optimization
03

Build NewAdd-ons

>>
We help our Clients to add new features: Additional pages, add payment gateway, load products to your store or build a new e-commerce store.