天天看點

修正memcache.php中的錯誤示例

使用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

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

<code>736 </code><code>echo</code> <code>'&lt;tr class=tr-0&gt;&lt;td class=td-0&gt;Start Time&lt;/td&gt;&lt;td&gt;'</code><code>,</code><code>date</code><code>(DATE_FORMAT,$memcacheStatsSingle[$server][</code><code>'STAT'</code><code>][</code><code>'time'</code><code>]-$memcacheStatsSingle[$server][</code><code>'STAT'</code><code>][</code><code>'uptime'</code><code>]),</code><code>'&lt;/td&gt;&lt;/tr&gt;'</code><code>;</code>

解決辦法:

之上增加一行

date_default_timezone_set("PRC");

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

本文轉自 bannerpei 51CTO部落格,原文連結:http://blog.51cto.com/281816327/1622008,如需轉載請自行聯系原作者