1. 程式人生 > >It is not safe to rely on the system's timezone settings

It is not safe to rely on the system's timezone settings

ted mil ext app eight upload 大神 hose 老師

在寫php文件上傳程序時有時會出現這樣的警告:

Upload: 屏幕截圖2014-09-28_160214.png
Type: image/png
Size: 66.84765625 Kb
Temp file: D:\Users\Aven\AppData\Local\Temp\php742F.tmp

Warning: move_uploaded_file() [function.move-uploaded-file]: 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 ‘UTC‘ for ‘8.0/no DST‘ instead in F:\PHP\upload_file.php on line 26

Warning: move_uploaded_file(upload/屏幕截圖2014-09-28_160214.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in F:\PHP\upload_file.php on line 26

Warning: move_uploaded_file() [function.move-uploaded-file]: 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 ‘UTC‘ for ‘8.0/no DST‘ instead in F:\PHP\upload_file.php on line 26

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘D:\Users\Aven\AppData\Local\Temp\php742F.tmp‘ to ‘upload/屏幕截圖2014-09-28_160214.png‘ in F:\PHP\upload_file.php on line 26
Stored in: upload/屏幕截圖2014-09-28_160214.png
這是因為PHP所取的時間是格林威治標準時間,所以和你當地的時間會有出入格林威治標準時間和北京時間大概差8個小時左右,我們可以按照下面的方法解決:
1、在頁頭使用date_default_timezone_set()設置我的默認時區為北京時間,即 <?php date_default_timezone_set("PRC"); ?>就可以了。
2、在php.ini中設置date.timezone的值為PRC,設置好以後的為:date.timezone=PRC,同時取消這一行代碼的註釋,即去掉前面的分號就可以了。

這裏選用修改配置文件的方式解決問題:

用Notepad++打開php.ini,

技術分享圖片

查找“date.timezone”,把語句前的分號去掉,值設置為“PRC”,重啟FastCGI服務,問題解決。

技術分享圖片

再分享一下我老師大神的人工智能教程吧。零基礎!通俗易懂!風趣幽默!還帶黃段子!希望你也加入到我們人工智能的隊伍中來!http://www.captainbed.net

It is not safe to rely on the system's timezone settings