當運行程序時,會出現如下警告:
Warning: strftime(): 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 /home/wwwroot/cj.fbb.gamedo.com.cn/smarty/sysplugins/smarty_internal_runtime_codeframe.php on line 49
原因:php默認是以格林威治標准時間(UTC)為准進行時間轉換,因為自己所處的當地時間與UTC會有出入,格林威治標准時間和北京時間有8個小時的時間差,所以必須為php指定一個時區,讓PHP知道以那個失去為准進行轉換
解決方法:
1、在PHP程序頭部使用date_default_timezone_set()設置我的默認時區為北京時間(PRC,中國的英文縮寫)即 date_default_timezone_set("PRC") 這種方法必須在每個使用date的文件中添加相關函數
2、在php.ini 中找到date.timezone 行,支持前面的 “ ; ” 號,並將它的值設置為PRC,設置好以后為:date.timezone = "Asia/Shanghai"