PHP調試的時候出現了警告:

來源:互聯網
上載者:User

標籤:cte   get   clu   date   添加   com   選項   hang   時間函數   

PHP調試的時候出現了警告:

It is not safe to rely on the system解決方案,其實就是時區設定不正確造成的,本文提供了3種方法來解決這個問題。

實際上,從PHP 5.1.0開始當對使用date()等函數時,如果timezone設定不正確,在每一次調用時間函數時,都會產生E_NOTICE 或者 E_WARNING 資訊,而又在php中,date.timezone這個選項,預設情況下是關閉的,無論用什麼php命令都是格林威治標準時間,但是PHP5.3中如果沒有設定部分時間類函數也會強行拋出了這個錯誤的。
PS:現在由於大部分人使用VPS/雲主機,需要自己配置的環境的就更加會容易出現這個情況。
建議:不熟悉PHP環境還是用比較成熟的一鍵安裝包吧。

 

方法1:

(最好的方法)在php.ini裡加上找到date.timezone項,設定date.timezone = "Asia/Shanghai",重啟環境就ok了。

 

方法2:

在需要用到這些時間函數的時候,在頁面添加date_default_timezone_set("PRC");

 

方法3:

在頁頭加上設定時區ini_set(‘date.timezone‘,‘Asia/Shanghai‘);

 

錯誤碼:
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 ‘Asia/Chongqing’ for ‘CST/8.0/no DST’ instead

Warning: strtotime(): 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 ‘Asia/Chongqing’ for ‘CST/8.0/no DST’ instead

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 case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Asia/Chongqing‘ for ‘CST/8.0/no DST‘ instead in <b>/home/ftp/n/nimaboke/include/lib/function.base.php

 http://beikeit.com/post-682.html

 

PHP調試的時候出現了警告:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.