How to change the timezone in CodeIgniter 3.1.6

date_default_timezone_set() function is used to sets the default timezone used by all date or time functions in core PHP, CodeIgniter etc.

date_default_timezone_set();
date_default_timezone_set('Asia/Kolkata');

# Option-1:
In case of CodeIgniter, we can set the default timezone in the
application/config.php file

In case of CodeIgniter, we can set the default timezone in the
application/config.php file

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

date_default_timezone_set('Asia/Kolkata');

# Option-2:
Place the code in the main index.php of Codeigniter folder

date_default_timezone_set('Asia/Kolkata');

Leave a Reply

Your email address will not be published. Required fields are marked *