Changing time zone after connecting to database using "set time_zone = ..."
mysql, pdo, php, sql, timezone
Solution
With some help of others (see comments), I managed to find the code that does the job:
$pdo = new PDO('mysql:host=localhost;dbname=exampletable',
'exampleuser',
'examplepassw',
[PDO::MYSQL_ATTR_INIT_COMMAND =>"SET NAMES utf8;SET time_zone = 'Europe/London'"]);
Problem
I'm trying to change the time zone to "Europe/London" right after connecting to my database. This was my original code: ``` $pdo = new PDO('mysql:host=localhost;dbname=exampletable', 'exampleuser', 'examplepassw', array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'); ``` And I changed it into the following code but apparently that's not the right way to change the time zone cause I get an error. ``` $pdo = new PDO('mysql:host=localhost;dbname=exampletable', 'exampleuser', 'examplepassw', array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', 'SET time_zone = 'Europe/London'')); ``` How can I change the time zone starting from PDO?