Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the time zone in Codeigniter

my project is hosted on shared server and i want to change the timezone to Asia/Kolkata. i have tried setting timezone using htaccess file but failed.

like image 515
Ashutosh Mishra Avatar asked Aug 24 '11 05:08

Ashutosh Mishra


2 Answers

With CodeIgniter, the best place to set the timezone is inside the main index.php file. It's at the same level in your project structure as the system/ and application/ folders.

Just add the following as the first line of code in the file after the opening <?php tag:

date_default_timezone_set('Asia/Kolkata');

That should do it for all your PHP code.

Don't forget that if you're using a database, the timezone for the database will probably be different as well. If you're using MySQL, you'll want to do a SET time_zone = "+05:30" query as soon as you open a database connection.

like image 64
zombat Avatar answered Sep 21 '22 03:09

zombat


Try this

date_default_timezone_set('Asia/Kolkata');

in your index.php file. You don't need to have access to your php.ini file.

like image 22
royrui Avatar answered Sep 22 '22 03:09

royrui