I might be lazy, but this question seems easier to just ask than to go laborating for. I have been able to set time-zone with mysql cli, with the query
SET @@session.time_zone = "+01:00";
I wonder, for a php web application (that keeps a users time-zone), how often must this query be made. Is it for every connection to the MySql/MariaSql database engine?
Advertisement
Answer
I have done some googling and it showed that the setting of time-zone for a web-app having users in different time zones – is done at every db connect.
$offset = "+01:00"; $db->exec("SET time_zone='$offset';");
https://www.sitepoint.com/synchronize-php-mysql-timezone-configuration/
This question is actually deeper, and involves the field-type in the db, should it be TIMESTAMP or Datetime.
NB I found by reading – and by some experience, that it’s better to let the timezone setting rest upon PHP, and letting the MySql db be unaware of timezones… keeping db to GMT.
See this for reference: PHP, MySQL and Time Zones