Skip to content

Commit

Permalink
Merge pull request #1495 from d-bro/timezone
Browse files Browse the repository at this point in the history
Feature request 1312: Added configuration option for setting the timezone of the current database connection
  • Loading branch information
lem9 committed Feb 10, 2015
2 parents c28406e + 8955c09 commit 80da5e5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/config.rst
Expand Up @@ -904,6 +904,18 @@ Server connection settings
rows in :config:option:`$cfg['Servers'][$i]['table_uiprefs']` and automatically
delete older rows.

.. config:option:: $cfg['Servers'][$i]['SessionTimeZone']
:type: string
:default: ``''``

Sets the time zone used by phpMyAdmin. Leave blank to use the time zone of your
database server. Possible values are explained at
http://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html

This is useful when your database server uses a time zone which is different from the
time zone you want to use in phpMyAdmin.

.. config:option:: $cfg['Servers'][$i]['AllowRoot']
:type: boolean
Expand Down
25 changes: 25 additions & 0 deletions libraries/common.inc.php
Expand Up @@ -981,6 +981,31 @@
$cfg['Server']['user'], $cfg['Server']['password'], false
);

// Set timestamp for the session, if required.
if ($cfg['Server']['SessionTimeZone'] != '') {
$sql_query_tz = 'SET ' . PMA_Util::backquote('time_zone') . ' = '
. '\'' . PMA_Util::sqlAddSlashes($cfg['Server']['SessionTimeZone']) . '\'';

if(! $userlink->query($sql_query_tz)) {
$error_message_tz = sprintf(__('Unable to use timezone %s for server %d. '
. 'Please check your configuration setting for '
. '[em]$cfg[\'Servers\'][%d][\'SessionTimeZone\'][/em]. '
. 'phpMyAdmin is currently using the default time zone of the database server.'),
$cfg['Servers'][$GLOBALS['server']]['SessionTimeZone'],
$GLOBALS['server'],
$GLOBALS['server']
);

$GLOBALS['error_handler']->addError(
$error_message_tz,
E_USER_WARNING,
'',
'',
false
);
}
}

if (! $controllink) {
$controllink = $userlink;
}
Expand Down
8 changes: 8 additions & 0 deletions libraries/config.default.php
Expand Up @@ -493,6 +493,14 @@
*/
$cfg['Servers'][$i]['MaxTableUiprefs'] = 100;

/**
* Sets the time zone used by phpMyAdmin. Possible values are explained at
* http://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html
*
* @global string $cfg['Servers'][$i]['SessionTimeZone'] = ''
*/
$cfg['Servers'][$i]['SessionTimeZone'] = '';

/**
* whether to allow root login
*
Expand Down

0 comments on commit 80da5e5

Please sign in to comment.