Php wrong timezone

My PHP mail is sending with the wrong date and time. I set the PHP time:

date_default_timezone_set('Europe/Brussels'); 

and when I

 echo date('r'); //returns correctly: Thu, 02 Aug 2012 13:28:00 

I get the right time. However, when I send mail, the mail date is time + 1 day + 1 hour.

I searched around and found some old documents where it was a PHP error or so, but they date from 2001 and 2005, so I assume that I am doing something else wrong ... I expect that the error in sending is not there will be mail since it is being sent, but I will still send my code:

 <?php session_start(); date_default_timezone_set('Europe/Brussels'); $receiver = ' test@yourhost.com '; $subject = 'Test'; $message = 'This is a test'; $receiver = $email; $headers = "From: me@myhost.com " . "\r\n" . "X-Mailer: PHP/" . phpversion(); if(mail($receiver,$subject,$message,$headers)){ //This is done } ?> 
+4
source share
2 answers

Read the following: -

http://php.net/manual/en/function.date-default-timezone-set.php

http://php.net/manual/en/function.date-default-timezone-get.php

or

try it

 date_default_timezone_set( 'America/New_York' ); 

//or

 ini_set('date.timezone', 'America/Los_Angeles'); 
+2
source

This is the wrong setting for your php.ini
in your php.ini, do a search:

 ; date.timezone 

replace whit:

 date.timezone = America/New_York 

and restart apache

List of supported time zones:
http://www.php.net/manual/en/timezones.php

Edit: in htaccess, the time zone should be used this way:

 php_value date.timezone "Europe/Brussels" 
+3
source

All Articles