在将培训人员分配给沙特阿拉伯的课程和培训人员时,我正在使用ical向其发送电子邮件事件。将电子邮件事件发送到自动添加到他们的电子邮件中的时间(用于计时)时,这与我传递给ical的时间有误,请提供建议并帮助我将时间设置为ical(我传递给ical)。
这是我使用的功能:
function sendIcalEvent($from_name, $from_address, $to_name, $to_address, $BCC_to_address, $startTime, $endTime, $subject, $description, $location, $course_title, $loc_title)
{
$domain = 'testdomain.com';
$mime_boundary = "----Training Booking----".MD5(TIME());
$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";
$headers .= "BCC: ".$BCC_to_address."\n";
$message = "--$mime_boundary\r\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>'.$description.'</p>';
$message .= "</body>\n";
$message .= "</html>\n";
$message .= "--$mime_boundary\r\n";
$ical = 'BEGIN:VCALENDAR' . "\r\n" .
'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "\r\n" .
'VERSION:2.0' . "\r\n" .
'METHOD:REQUEST' . "\r\n" .
'BEGIN:VTIMEZONE' . "\r\n" .
'TZID:Arabia Standard Time' . "\r\n" .
'BEGIN:STANDARD' . "\r\n" .
'DTSTART:16011028T030000' . "\r\n" .
'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10' . "\r\n" .
'TZOFFSETFROM:+0300' . "\r\n" .
'TZOFFSETTO:+0200' . "\r\n" .
'TZNAME:EST' . "\r\n" .
'END:STANDARD' . "\r\n" .
'BEGIN:DAYLIGHT' . "\r\n" .
'DTSTART:16010325T020000' . "\r\n" .
'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3' . "\r\n" .
'TZOFFSETFROM:+0200' . "\r\n" .
'TZOFFSETTO:+0300' . "\r\n" .
'TZNAME:EDST' . "\r\n" .
'END:DAYLIGHT' . "\r\n" .
'END:VTIMEZONE' . "\r\n" .
'BEGIN:VEVENT' . "\r\n" .
'ORGANIZER;CN="'.$from_name.'":MAILTO:'.$from_address. "\r\n" .
'ATTENDEE;CN="'.$to_name.'";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:'.$to_address. "\r\n" .
'LAST-MODIFIED:' . date("Ymd\TGis") . "\r\n" .
'UID:'.date("Ymd\TGis", strtotime($startTime)).rand()."@".$domain."\r\n" .
'DTSTAMP:'.date("Ymd\TGis"). "\r\n" .
'DTSTART;TZID="Arabia Standard Time":'.date("Ymd\THis", strtotime($startTime)). "\r\n" .
'DTEND;TZID="Arabia Standard Time":'.date("Ymd\THis", strtotime($endTime)). "\r\n" .
'TRANSP:OPAQUE'. "\r\n" .
'SEQUENCE:1'. "\r\n" .
'SUMMARY:' . $course_title . "\r\n" .
'LOCATION:' . $loc_title . "\r\n" .
'CLASS:PUBLIC'. "\r\n" .
'PRIORITY:5'. "\r\n" .
'BEGIN:VALARM' . "\r\n" .
'TRIGGER:-PT15M' . "\r\n" .
'ACTION:DISPLAY' . "\r\n" .
'DESCRIPTION:Reminder' . "\r\n" .
'END:VALARM' . "\r\n" .
'END:VEVENT'. "\r\n" .
'END:VCALENDAR'. "\r\n";
$message .= 'Content-Type: text/calendar;name="Training_Session.ics";method=REQUEST'."\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= $ical;
$mailsent = mail($to_address, $subject, $message, $headers);
return ($mailsent)?(true):(false);
}
并将其称为
$dtstart = date("m/d/Y", strtotime($session_details['start_date']));
$dtend = date("m/d/Y", strtotime($session_details['end_date']));
sendIcalEvent($from_name, $from_address, $to_name, $to_address, $BCC_to_address, $startTime, $endTime, $subject, $description, $location, $course_title, $loc_title)
我希望在iCal时区问题中遇到此问题。如何将其设置为(沙特阿拉伯利雅得)?
答案 0 :(得分:0)
ics规范建议使用Ohlson时区db标识符(与php相同),请参见https://tools.ietf.org/html/rfc5545#page-27。看起来您需要的TZID是亚洲/利雅得。参见http://php.net/manual/en/timezones.asia.php。
请参见https://tools.ietf.org/html/rfc5545#page-35 可以以UTC时间发布日期时间,然后让应用程序转换为用户时区
DTSTART:19970714T173000Z ; UTC time
或带有TZID(应用程序会将其转换为应用程序中用户的时区)
DTSTART;TZID=America/New_York:19970714T133000 ; Local time and time zone reference.
列出的另一个选项是“本地或浮动时间”。例如,如果事件是上午8点,那么在所有时区都是上午8点。