Reputation: 7843
Is there anyway I can change the session timezone of PHPMyAdmin?
I'm using a foreign MySQL server that I could not change timezone of. I want to see timestamps at my timezone in all my PHPMyAdmin sessions. Is there any "session script" I can set so they runs on every PHPMyAdmin session? Or is there any other way to do so?
Upvotes: 4
Views: 727
Reputation: 3237
phpMyAdmin does reset the session timezone after each SQL query in the SQL
tab.
Set session timezone and check current time in timezone:
SET SESSION time_zone = '+10:00';
SELECT @@system_time_zone, @@global.time_zone, @@session.time_zone;
SELECT NOW();
| @@system_time_zone | @@global.time_zone | @@session.time_zone
| CEST | SYSTEM | +10:00
2022-04-14 21:06:46
Next run without setting the session timezone again:
SELECT @@system_time_zone, @@global.time_zone, @@session.time_zone;
SELECT NOW();
| @@system_time_zone | @@global.time_zone | @@session.time_zone
| CEST | SYSTEM | SYSTEM
2022-04-14 13:07:23
Second run shows that the session timezone was reset to CEST +02:00
which has 8 hours difference with +10:00
which explains the current time difference between the 2 requests.
I could not find how to set the session timezone in phpMyAdmin so I had to set the session timezone at the start of each SQL
request.
Upvotes: 1
Reputation: 5846
Patched libraries/dbi/DBIMysqli.class.php as a workaround.
Telling mysqli to use phps default timezone, could be replaced with a string.
--- a/libraries/dbi/DBIMysqli.class.php 2016-03-11 09:09:27.538801633 +0100
+++ b/libraries/dbi/DBIMysqli.class.php 2016-03-11 09:12:15.099759342 +0100
@@ -223,6 +223,8 @@ class PMA_DBI_Mysqli implements PMA_DBI_
return false;
}
+ $link->query("SET time_zone = '" . date("P"). "'");
+
return $link;
}
Upvotes: 1