codeigniter How to set time zone in CodeIgniter How to set the time zone in CodeIgniter


Placing date_default_timezone_set('Asia/Kolkata'); on config.php above base URL also works.

PHP List of Supported Time Zones



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


Another way I have found useful is if you wish to set a time zone for each user:

  • Create a MY_Controller.php file.

  • Create a column in your user table you can name it timezone or any thing you want to. So that way, when user selects his time zone, it can can be set to his timezone when login.



class MY_Controller extends CI_Controller {

    public function __construct() {

    public function set_timezone() {
        if ($this->session->userdata('user_id')) {
            $this->db->from($this->db->dbprefix . 'user');
            $this->db->where('user_id', $this->session->userdata('user_id'));
            $query = $this->db->get();
            if ($query->num_rows() > 0) {
            } else {
                return false;

Also, to get the list of time zones in PHP:

 $timezones = DateTimeZone::listIdentifiers(DateTimeZone::ALL);

 foreach ($timezones as $timezone) {
    echo $timezone;
    echo "<br />";