修正memcache.php中的錯誤示例

yzf01發表於2021-09-09

使用memcache.php監控memcache後,在頁面報時間格式的錯誤:

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in/usr/local/nginx/html/memcache.phpon line 736


根據提示可以列出memecache.php相關的行數內容;

1 24 define('DATE_FORMAT','Y/m/d H:i:s');
';
1 736 echo '
Start Time ',date(DATE_FORMAT,$memcacheStatsSingle[$server]['STAT']['time']-$memcacheStatsSingle[$server]['STAT']['uptime']),'

解決辦法:

1 24 define('DATE_FORMAT','Y/m/d H:i:s');

之上增加一行

date_default_timezone_set("PRC");


其他方法,例如在php.ini中設定date.timezone的值,無論怎麼設定和重啟PHP-FPM程式都不生效,這點比較奇怪;



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2334/viewspace-2805077/,如需轉載,請註明出處,否則將追究法律責任。

相關文章