4

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?

Koala Yeung
  • 7,475
  • 3
  • 30
  • 50
  • This will help you: http://stackoverflow.com/questions/8434030/how-to-correctly-set-mysql-timezone – Sathish D Nov 11 '13 at 11:39
  • In my case, I want all servers to use UTC for syncing purposes, php set the timezone for the domain it serves => diferent time zone for our ".co.uk" and our ".se" sites. in phpMyAdmin, I prefer to have the timezone where we developers are. – Puggan Se Mar 11 '16 at 08:05

2 Answers2

1

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;
     }
Puggan Se
  • 5,738
  • 2
  • 22
  • 48
1

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.

8ctopus
  • 2,617
  • 2
  • 18
  • 25