登錄OSB管理頁面時報date_default_timezone_set()解決方法

登錄OSB管理頁面時報時區錯誤如下:

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 had to select 'UTC' because your platform doesn't provide functionality for the guessing algorithm in /apps/oracle/OSBackup/apache/htdocs/php/common.php on line 1963

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 had to select 'UTC' because your platform doesn't provide functionality for the guessing algorithm in /apps/oracle/OSBackup/apache/htdocs/php/common.php on line 1964

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 had to select 'UTC' because your platform doesn't provide functionality for the guessing algorithm in /apps/oracle/OSBackup/apache/htdocs/php/common.php on line 1965

Warning: strftime() [function.strftime]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 had to select 'UTC' because your platform doesn't provide functionality for the guessing algorithm in /apps/oracle/OSBackup/apache/htdocs/php/common.php on line 1966

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 had to select 'UTC' because your platform doesn't provide functionality for the guessing algorithm in /apps/oracle/OSBackup/apache/htdocs/php/common.php on line 1968

Cause:
這是因爲PHP所取的時間是格林威治標準時間,所以和你當地的時間會有出入格林威治標準時間和北京時間大概差8個小時左右,我們可以按照下面的方法解決。

解決辦法:

1、在頁頭使用date_default_timezone_set()設置我的默認時區爲北京時間,即

<?php

date_default_timezone_set("PRC");

?>就可以了。

2、在php.ini中設置date.timezone的值爲PRC,設置好以後的爲:date.timezone=PRC,同時取消這一行代碼的註釋,即去掉前面的分號就可以了。

 

打開php5.ini查找date.timezone 去掉前面的分號 = 後面加XXX,重啓http服務(如apache2或iis等)即可。
XXX可以任意正確的值。對於我們國內來 說:可以爲以下值:Asia/Chongqing ,Asia/Shanghai ,Asia/Urumqi (依次爲重慶,上海,烏魯木齊)港臺地區可用:Asia/Macao ,Asia/Hong_Kong ,Asia/Taipei (依次爲澳門,香港,臺北),還有新加坡:Asia/Singapore,當然PRC也行。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章