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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With