php - How do I adjust the timezone information when sending this iCal invite?
I am trying to send a calendar request mail through my php code. I got the mail along with the calendar. But I have a problem in the start date. How to configure the start date according to Gulf Standard Time. Now I am getting according to GMT, though I did not mention anywhere. That means in short, if I will send a request on 7am then in the start date it will show 11 am. My code is like:
$dtstart = $start_date_conf;
$dtend=$end_date_conf;
$todaystamp = date("Ymd\THis\Z");
//Create unique identifier
$cal_uid = date('Ymd').'T'.date('His')."-".rand()."@fugenx.com";
//Create Mime Boundry
$mime_boundary = "----Bespot Meeting Booking----".md5(time());
//Create Email Headers
$headers = "From: ".$from_name." <".$from_address.">\n";
$headers .= "Reply-To: ".$from_name." <".$from_address.">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";
$headers .= "Content-class: urn:content-classes:calendarmessage\n";
//Create Email Body (HTML)
$message .= "--$mime_boundary\n";
$message .= "Content-Type: text/html; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= "<html>\n";
$message .= "<body>\n";
$message .= '<p>'.$messagess.'</p>';
$message .= '<p></p><p></p>';
$message .= '<p><b>Thanks & Regards,:</b></p>';
$message .= '<p>'.$full_name.'</p>';
$message .= '<p>'.$full_address.'</p>';
$message .= '<p>'.$email_address.'</p>';
$message .= '<p>'.$mobile_number.'</p>';
$message .= "</body>\n";
$message .= "</html>\n";
$message .= "--$mime_boundary\n";
//Create ICAL Content (Google rfc 2445 for details and examples of usage)
$ical = "BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
ORGANIZER:MAILTO:".$from_address."
DTSTART:".$dtstart."
DTEND:".$dtend."
LOCATION:".$meeting_location."
TRANSP:OPAQUE
SEQUENCE:0
UID:".$cal_uid."
DTSTAMP:".$todaystamp."
DESCRIPTION:".$meeting_description."
SUMMARY:".$subject."
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR";
$message .= "Content-Type: text/calendar;method=REQUEST;charset=utf-8\n";
//$message .= "Content-Type: text/calendar;name=\"meeting.ics\";method=REQUEST\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= $ical;
//SEND MAIL
$mail_sent = @mail( $email, $subject, $message, $headers );
Answer
Solution:
see RFC5545, you need to add a vtimezone component to refer the TZID to it