我正在尝试在 PHP 中动态生成 ics 文件,其中时区根据给定的位置是动态的。一切正常,但存在日光时间问题,即它显示一小时左右的时差。现在要解决这个问题,我必须DAYLIGHT
动态使用。但我不知道如何动态使用它,或者我可以从哪里获得TZOFFSETFROM
与TZOFFSETTO
给定时区相关的偏移量。
例如:
$timeZone = "America/Denver" // dynamically fetched from DB
$ical = "BEGIN:VCALENDAR\n";
$ical .= "VERSION:2.0\n";
$ical .= "PRODID:-//LokalMotion//LokalMotion Events v1.0//EN\n";
$ical .= "CALSCALE:GREGORIAN\n";
$ical .= "METHOD:PUBLISH\n";
$ical .= "X-WR-CALNAME:LokalMotion Events\n";
$ical .= "X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n";
$ical .= "BEGIN:VTIMEZONE\n";
$ical .= "TZID:{$timeZone}\n";
$ical .= "TZURL:http://tzurl.org/zoneinfo-outlook/{$timeZone}\n";
$ical .= "X-LIC-LOCATION:{$timeZone}\n";
$ical .= "END:VTIMEZONE\n";
$ical .= "BEGIN:VEVENT\n";
$ical .= "DTSTAMP:".date('Ymd\THis\Z')."\n";
$ical .= "DTSTART;TZID={$timeZone}:{$start_date}\n";
$ical .= "DTEND;TZID={$timeZone}:{$end_date}\n";
$ical .= "STATUS:CONFIRMED\n";
$ical .= "SUMMARY:{$title}\n";
$ical .= "DESCRIPTION:{$description}\n";
$ical .= "ORGANIZER;CN=Reminder:MAILTO:support@mysite.com\n";
$ical .= "CLASS:PUBLIC\n";
$ical .= "CREATED:{$start_date}Z\n";
$ical .= "LOCATION:{$location}\n";
$ical .= "URL:http://www.mysite.com\n";
$ical .= "SEQUENCE:1\n";
$ical .= "LAST-MODIFIED:".date('Ymd\THis\Z')."\n";
$ical .= "UID:{$title}-support@mysite.com\n";
$ical .= "END:VEVENT\n";
$ical .= "END:VCALENDAR";
echo $ical;
现在如何根据位置动态使用日光,例如位置可以是“美国/加拉加斯”......等
$ical .= "BEGIN:DAYLIGHT";
$ical .= "TZOFFSETFROM:{}"; //I need this dynamic
$ical .= "TZOFFSETTO:{}";//I need this dynamic
$ical .= "TZNAME:EDT";
$ical .= "DTSTART;TZID={$timeZone}:{$start_date}\n";
$ical .= "RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU";
$ical .= "END:DAYLIGHT";
提前致谢。