PHP 5.3+ 強制要求設定時區,否則 date() 函數會拋出 E_WARNING 導致 Yii 框架噴出 500 錯誤:「It is not safe to rely on the system's timezone settings.」
Error 500
date() [function.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.
date.timezone = "Asia/Shanghai"
修改後重啟 Apache/PHP-FPM。
<?php
date_default_timezone_set("PRC"); // 或 "Asia/Shanghai"
?>
置於入口腳本(如 index.php)最開頭,確保在任何 date() 呼叫前執行。
建立 test.php:<?php echo date('Y-m-d H:i:s'); ?>,確認輸出正確且無警告。
Asia/Shanghai 或 PRCAsia/TaipeiAsia/Hong_KongUTC設定正確後,Yii 需求檢查頁面將顯示「通過」,框架正常運作。