My PHP mail is sent with a wrong date & time.
I’ve set my 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 correct time. When I send a mail however, the date of the mail is the time now + 1 day + 1 hour.
I’ve searched around and found some old docs where it was a PHP bug or so, but those date from 2001 and 2005 so I presume I’m doing someting else wrong… I expect theres no error in the sending of the mail, since it does get sent, but I’ll post my code anyway:
<?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
}
?>
Read this :-
http://php.net/manual/en/function.date-default-timezone-set.php
http://php.net/manual/en/function.date-default-timezone-get.php
or
try this
//or