diff --git a/doc/config.rst b/doc/config.rst index 58a0ac69eb..26e0739d55 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -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 diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 31f688fac3..7d2cb0d908 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -981,6 +981,31 @@ if (! defined('PMA_MINIMUM_COMMON')) { $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; } diff --git a/libraries/config.default.php b/libraries/config.default.php index 3b6d2a288a..df4f117bd2 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -493,6 +493,14 @@ $cfg['Servers'][$i]['central_columns'] = ''; */ $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 *