php - Codeigniter Default Timezone Issue -


brief: working on codeigniter3.0.3 version application. multi-tenant application. single code base connects multiple databases based on user login (interacts different database). each user different timezone across globe. trying apply below code.

date_default_timezone_set("africa/accra"); $time =  date('y-m-d h:i:s');echo $time; $expiry=$this->db->get_where('settings', array('type' => 'registration_date'))->row()->description; $timestamp=strtotime($expiry); echo date('y-m-d h:i:s',$timestamp); 

the second line of code shows time accordingly, whereas last line showing server time.

the description column of setting table of varchar type stored value "2016-02-08 16:29:09".

also, if add date_default_timezone_set("africa/accra") before last line, working fine.

question : have tried setting property in index.php, config.php, controller construct method, created helper library, none of them seems have worked. how can resolve please?

edit : date value stored in db before applying timezone_set. there no offset in db before.

as of don't know timezone each of users. can set gmt , update columns accordingly too. need update existing date columns based on timezone set? but, happen if user changes timezone prefer? there other workaround this?

place

date_default_timezone_set("africa/accra"); 

in index.php file


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -