今天在安裝ECSHOP時遇到警告如下:
Warning: date_default_timezone_get(): 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 ...
很明顯是由於PHP默認的時間區域設置問題導致的警告
date_default_timezone_get — 取得一個腳本中所有日期時間函數所使用的默認時區
默認時區,使用如下“假定”的順序:
用 date_default_timezone_set() 函數設定的時區(如果設定了的話)
僅僅在 PHP 5.4.0 之前: TZ 環境變量(如果非空)
date.timezone 配置選項(如果設定了的話)
僅僅在 PHP 5.4.0 之前: 查詢操作系統主機 (如果操作系統支持並允許)。
如果以上選擇都不成功,date_default_timezone_get() 會則返回 UTC 的默認時區。
最簡單的解決辦法:
vim /etc/php.ini
找到date.timezone
將它的改為 date.timezone=utc 將前面的分號去掉,重啟服務器
或者在index.php中加上 date_default_timezone_set('UTC');