Tutorialsplane

Set default timezone in codeigniter

Set default timezone in codeigniter : date_default_timezone_set() is used to set the default timezone in codeigniter.

Best way to set set default timezone in codeigniter is add date_default_timezone_set(‘America/Los_Angeles’) in index.php

Set default timezone in codeigniter

/*add this in the top of index.php located at the root of application.*/
date_default_timezone_set('America/Los_Angeles');

Another way to set default timezone in codeigniter is Add the

Set default timezone in codeigniter controller

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Link extends MY_controller{
     public function __construct() {
        parent::__construct();
        date_default_timezone_set('America/Los_Angeles');        
        }
    public function index()
	{
            echo $date = date("Y-m-d H:i:s");
           // your code goes here..
	}

}
??>