2017-06-17 27 views
0

錯誤:可用 埃羅吶Linha:#3274 :: date_default_timezone_get():這是不是安全的依靠系統的時區設置。您需要需要才能使用date.timezone設置或date_default_timezone_set()函數。如果您使用這些方法中的任何一種,並且仍然收到此警告,則很可能是拼寫錯誤的時區標識符。我們現在選擇了「UTC」時區,但請設置date.timezone以選擇您的時區。 C:\ AppServ \ www \ class \ phpmailer.class.php Erro no envio do電子郵件:SMTP連接()失敗。PHPMailer的date_default_timezone_get():這是不是安全的依靠系統的時區設置

public static function rfcDate() 
{ 
    // Set the time zone to whatever the default is to avoid 500 errors 
    // Will default to UTC if it's not set properly in php.ini 
    date_default_timezone_set(@date_default_timezone_get()); 
    return date('D, j M Y H:i:s O'); 
} 

回答

0

PHP沒有設置默認時區。

使用PHPMailer的(或者說對時區使用的任何類),你應該在php.ini

[Date] 
; Defines the default timezone used by the date functions 
; http://php.net/date.timezone 
date.timezone = 'Australia/Sydney' 

設置date.timezone或通過調用date_default_timezone_set()函數YOUT代碼(配置PHP之前PHPMailer的前)

date_default_timezone_set('Australia/Sydney'); 

或在Apache的配置文件(我的首選方法)

# Timezone and other stuff for PHP 
php_value date.timezone "Australia/Sydney" 
0

你應該先以設置默認的時區使用date_default_timezone_set,然後使用 date_default_timezone_get檢索。

date_default_timezone_set — Sets the default timezone used by all date/time functions in a script

date_default_timezone_get — Gets the default timezone used by all date/time functions in a script

一個例子是:

date_default_timezone_set('America/Los_Angeles'); 

$x= date_default_timezone_get(); // 'America/Los_Angeles' 

什麼目前你正在做的是試圖請求的默認時區,爲了使用它的價值爲您date_default_timezone_set電話,但它從來沒有將開始使用。

+0

問題中的代碼不是用戶代碼。它是PHPMailer的一部分,但這個答案也是正確的。 – geekasylum

相關問題