![]() |
Each user can set timezone - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Each user can set timezone (/showthread.php?tid=74599) Pages:
1
2
|
Each user can set timezone - esjdev - 10-13-2019 Exemple Code: date_default_timezone_set($user->timezone) How do I do it in Codeigniter? I tried to put in the MY_Controller of Core, which is the main controller of my system. Only it does not work. It only works if I put in index.php or constants.php. But it can't be read from Model to get user data for what I want to do. RE: Each user can set timezone - php_rocs - 10-13-2019 (10-13-2019, 10:10 AM)esjdev Wrote: Exemple @esjdev, Maybe this is what you are looking for... https://www.php.net/manual/en/function.date-default-timezone-set.php RE: Each user can set timezone - esjdev - 10-13-2019 (10-13-2019, 01:40 PM)php_rocs Wrote:(10-13-2019, 10:10 AM)esjdev Wrote: Exemple I know how the function works, the question and what in codeigniter doesn't work. This is my question ![]() RE: Each user can set timezone - dave friend - 10-13-2019 (10-13-2019, 10:10 AM)esjdev Wrote: But it can't be read from Model to get user data for what I want to do. What can't be read? The function you show sets the timezone. RE: Each user can set timezone - esjdev - 10-13-2019 (10-13-2019, 04:07 PM)dave friend Wrote:(10-13-2019, 10:10 AM)esjdev Wrote: But it can't be read from Model to get user data for what I want to do. It only works if I put "date_default_timezone_set ('UTC')" directly in index.php or constants.php, but I can't get the user's timezone in a database, as I want. RE: Each user can set timezone - InsiteFX - 10-14-2019 Not sure but this may be what your looking for, you need to be more specific about your problem. How To Synchronize Your PHP and MySQL Timezones RE: Each user can set timezone - php_rocs - 10-14-2019 @esjdev, What variable type is $user->timezone? String? Also, what values do you allow it to be? RE: Each user can set timezone - esjdev - 10-14-2019 (10-14-2019, 07:18 AM)php_rocs Wrote: @esjdev, This variable gets the specific user's Timezone from the database. RE: Each user can set timezone - jreklund - 10-14-2019 The recommended way are storing all time in UTC or GMT (whatever you prefer) and then use PHP DateTime to diff the time to the users timezone. If I remember correctly using that function mentioned can result in odd behavior as it affects all users in that PHP process. Here is an guide to do it. https://blog.serverdensity.com/handling-timezone-conversion-with-php-datetime/ RE: Each user can set timezone - esjdev - 10-14-2019 (10-14-2019, 10:39 AM)jreklund Wrote: The recommended way are storing all time in UTC or GMT (whatever you prefer) and then use PHP DateTime to diff the time to the users timezone. If I remember correctly using that function mentioned can result in odd behavior as it affects all users in that PHP process. Thanks, I will try this ![]() |