0

Error: Available Erro na Linha: #3274 :: 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone. C:\AppServ\www\class\phpmailer.class.php Erro no envio do e-mail: SMTP connect() failed.

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');
}
Guilherme
  • 107
  • 1
  • 1
  • 7

2 Answers2

0

You should first use date_default_timezone_set in order to set the default timezone, and then retrieve it using 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

An example is:

date_default_timezone_set('America/Los_Angeles');

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

What you are currently doing is trying to request the default timezone, in order to use its value for your date_default_timezone_set call, but it was never set to begin with.

Sotiris Kiritsis
  • 3,178
  • 3
  • 23
  • 31
0

PHP does not have a default timezone set.

Before using PHPMailer (or any class that makes use of time zones) you should configure PHP by setting date.timezone in PHP.INI

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

or by calling the date_default_timezone_set() function in yout code (before PHPMailer)

date_default_timezone_set('Australia/Sydney');

or in apache's configuration files (my preferred method)

# Timezone and other stuff for PHP
php_value date.timezone "Australia/Sydney"
geekasylum
  • 96
  • 1
  • 7