我为客户提供了一个可以发布活动的网站。而不是从iCal为每个事件手动创建.ics文件并上传它,而不是将其从数据库中拉出来并自动使用PHP自动创建一个.ics文件。
我可以从数据库中提取信息(没有问题),但是当将其转换为日历文件的时间戳时,这是一个艰难的时刻。这是我在数据库中存储的:
Month: 05
Day: 02
Year: 2011
Time: 11:30am - 1:30pm
以下是创建我的.ics文件的代码:
//This is the most important coding.
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=adamhouston_$id.ics");
echo "BEGIN:VCALENDAR\n";
echo "PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN\n";
echo "VERSION:2.0\n";
echo "METHOD:PUBLISH\n";
echo "X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n";
echo "BEGIN:VEVENT\n";
echo "CLASS:PUBLIC\n";
echo "CREATED:20091109T101015Z\n";
echo "DESCRIPTION:Speaker: $event_query_row[speaker_name]\\n\\nTopic: $event_query_row[speaker_topic]\n";
echo "DTEND:20100208T040000Z\n";
echo "DTSTAMP:20100109T093305Z\n";
echo "DTSTART:20100208T003000Z\n";
echo "LAST-MODIFIED:20091109T101015Z\n";
echo "LOCATION:$event_query_row[location]\n";
echo "PRIORITY:5\n";
echo "SEQUENCE:0\n";
echo "SUMMARY;LANGUAGE=en-us:ADAM-Houston Event\n";
echo "TRANSP:OPAQUE\n";
echo "UID:040000008200E00074C5B7101A82E008000000008062306C6261CA01000000000000000\n";
echo "X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n";
echo "X-MICROSOFT-CDO-IMPORTANCE:1\n";
echo "X-MICROSOFT-DISALLOW-COUNTER:FALSE\n";
echo "X-MS-OLK-ALLOWEXTERNCHECK:TRUE\n";
echo "X-MS-OLK-AUTOFILLLOCATION:FALSE\n";
echo "X-MS-OLK-CONFTYPE:0\n";
//Here is to set the reminder for the event.
echo "BEGIN:VALARM\n";
echo "TRIGGER:-PT1440M\n";
echo "ACTION:DISPLAY\n";
echo "DESCRIPTION:Reminder\n";
echo "END:VALARM\n";
echo "END:VEVENT\n";
echo "END:VCALENDAR\n";
现在我如何将数据库中的数据转换为正确的时间/日期戳?