Welcome Guest, Not a member yet? Register   Sign In
Each user can set timezone
#1

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.
Reply
#2

(10-13-2019, 10:10 AM)esjdev Wrote: 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.
 

@esjdev,
Maybe this is what you are looking for... https://www.php.net/manual/en/function.d...ne-set.php
Reply
#3

(10-13-2019, 01:40 PM)php_rocs Wrote:
(10-13-2019, 10:10 AM)esjdev Wrote: 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.
 

@esjdev,
Maybe this is what you are looking for... https://www.php.net/manual/en/function.d...ne-set.php

I know how the function works, the question and what in codeigniter doesn't work. This is my question Big Grin
Reply
#4

(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.
Reply
#5

(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.

What can't be read? The function you show sets the timezone.

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.
Reply
#6

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 )
Reply
#7

@esjdev,

What variable type is $user->timezone? String? Also, what values do you allow it to be?
Reply
#8

(10-14-2019, 07:18 AM)php_rocs Wrote: @esjdev,

What variable type is $user->timezone? String?  Also, what values do you allow it to be?

This variable gets the specific user's Timezone from the database.
Reply
#9

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/
Reply
#10

(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.

Here is an guide to do it.
https://blog.serverdensity.com/handling-...-datetime/

Thanks, I will try thisWink
Reply




Theme © iAndrew 2016 - Forum software by © MyBB