Welcome Guest, Not a member yet? Register   Sign In
Especific Time Zone by user
#1

Hello,

Im trying to set an specific time zone by user. The point is that the specific time_zone is set in a controller

PHP Code:
ini_set('date.timezone''America/Santo_Domingo'); 

Even date_default_timezone_set is not working

PHP Code:
date_default_timezone_set('America/Santo_Domingo'); 


If time zone is set in the root index.php file of whole project, everything works fine

Thanks in advance,
Ruben
Reply
#2

Usually, the best thing to do for something like this is to set the server's timezone in the index.php with date_default_timezone_set() (preferably to something like UTC, rather than the local time of wherever it happens to be hosted or you happen to be) and store any date/time data using that timezone. Then you can convert any times you've stored in the database to the user's timezone when you display them, using PHP's DateTime and DateTimeZone classes.

http://php.net/manual/en/datetime.settimezone.php
Reply




Theme © iAndrew 2016 - Forum software by © MyBB