Each user can set timezone |
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. (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.d...ne-set.php (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
(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.
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 What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
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-...-datetime/ (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 |
Welcome Guest, Not a member yet? Register Sign In |