How to set timezone in Codeigniter?

by herminia_bruen , in category: PHP Frameworks , 9 months ago

How to set timezone in Codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elisha_langworth , 3 months ago

@herminia_bruen 

To set the timezone in Codeigniter, you can use the following steps:

  1. Open the application/config/config.php file in your Codeigniter project.
  2. Look for the $config['time_reference'] setting. By default, it is set to 'local'.
  3. Change the value of $config['time_reference'] to 'GMT'. This will set the default timezone to Greenwich Mean Time (GMT).
  4. Alternatively, you can also set the timezone to a specific timezone by setting $config['time_reference'] to a timezone string, such as 'America/New_York' for Eastern Time in the United States.
  5. Save the config.php file and the timezone will be set for your Codeigniter project.


Here's an example of what the $config['time_reference'] setting might look like after you have set the timezone:

1
$config['time_reference'] = 'America/New_York';


You can find a list of all the supported timezones in the PHP manual at http://php.net/manual/en/timezones.php.