phpmyadmin3.x版在windows下的新版本php里日期显示乱码的补丁方案

> 这个问题应该在php5.5.30 与 7.3.11中不再出现。或许,这是灵异问题。 
因为近年一直使用在apache里以fast-cgi模式开以一个php5.3运行phpmyadmin;
前几天偶然发现这个问题并不存在了,或许以前真的只是灵异现象。

现象:

一直使用的phpmyadmin3.5版本(RELEASE-DATE-3.5.0,一个做了配置优化的版本 phpMyAdmin_3.5_path8.net),这个版本比较简洁,更新的pma有些臃肿。然而,在windows下使用php5.5, 及php7.0,都发现日期显示成乱码

phpmyadmin_35_date_string_bad

方案:

文件 libraries/common.lib.php , 行1648行

        $format = __('%B %d, %Y at %I:%M %p');

改成

        $format = '%Y-%m-%d %H:%M:%S';

即可,日期格式显示格式示例 2016-01-27 11:49:07

phpmyadmin_35_date_string_fixed

原因:

PMA_localisedDate函数使用了strftime()函数,该strftime函数第一个参数为日期格式,phpmyadmin源程序使用了带中文的格式字符串;而在windows下的php版本,在做格式化时会转成乱码。经确认linux下没有这个问题,pma是正常的。

更好的方案

$format = __('%B %d, %Y at %I:%M %p');
//patch for win
$fs_ver=explode('.',PHP_VERSION);
if( $fs_ver[0] > 5 or ($fs_ver[0] = 5 && $fs_ver[1] >= 4) ){
    if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'){
        $format = '%Y-%m-%d %H:%M:%S';
    }
}

亦即:github. 这样可以更好的兼容性。

 

mac osx下apache下的坑: you don't have permission to access / on this server

max osx下的apache实在别扭,配置文件被拆得支离破碎(虽然有点拆分还是有道理的),这倒可以慢慢适应。无语的是竟然报403错:

apache you don't have permission to access / on this server. mac

Apache/2.4.16 (Unix) PHP/5.5.29

google后,得知,要在Directory指令里,增加一条 Require all granted,如下示:

<Directory "/Users/jnovack/Sites/">
  Options Indexes MultiViews
  AllowOverride All
  # OSX 10.10 / Apache 2.4
  Require all granted
</Directory>

参考http://stackoverflow.com/questions/25250566/apache-localhost-403-error-with-yosemite

被mac osx坑死了。。。。