I made a website for a client where they can post events. Instead of manually creating .ics files from iCal for every event and uploading it, I though it would be better to pull it out of the database and automatically create a .ics file automatically with PHP.
I can pull information from the database (no problem), but when converting it to a time stamp for the calendar file it a tough one. Here's what I store in the database:
Month: 05
Day: 02
Year: 2011
Time: 11:30am - 1:30pm
Here's the code to create my .ics files:
//This is the most important coding.
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=adamhouston_$id.ics");
echo "BEGIN:VCALENDAR
";
echo "PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN
";
echo "VERSION:2.0
";
echo "METHOD:PUBLISH
";
echo "X-MS-OLK-FORCEINSPECTOROPEN:TRUE
";
echo "BEGIN:VEVENT
";
echo "CLASS:PUBLIC
";
echo "CREATED:20091109T101015Z
";
echo "DESCRIPTION:Speaker: $event_query_row[speaker_name]\n\nTopic: $event_query_row[speaker_topic]
";
echo "DTEND:20100208T040000Z
";
echo "DTSTAMP:20100109T093305Z
";
echo "DTSTART:20100208T003000Z
";
echo "LAST-MODIFIED:20091109T101015Z
";
echo "LOCATION:$event_query_row[location]
";
echo "PRIORITY:5
";
echo "SEQUENCE:0
";
echo "SUMMARY;LANGUAGE=en-us:ADAM-Houston Event
";
echo "TRANSP:OPAQUE
";
echo "UID:040000008200E00074C5B7101A82E008000000008062306C6261CA01000000000000000
";
echo "X-MICROSOFT-CDO-BUSYSTATUS:BUSY
";
echo "X-MICROSOFT-CDO-IMPORTANCE:1
";
echo "X-MICROSOFT-DISALLOW-COUNTER:FALSE
";
echo "X-MS-OLK-ALLOWEXTERNCHECK:TRUE
";
echo "X-MS-OLK-AUTOFILLLOCATION:FALSE
";
echo "X-MS-OLK-CONFTYPE:0
";
//Here is to set the reminder for the event.
echo "BEGIN:VALARM
";
echo "TRIGGER:-PT1440M
";
echo "ACTION:DISPLAY
";
echo "DESCRIPTION:Reminder
";
echo "END:VALARM
";
echo "END:VEVENT
";
echo "END:VCALENDAR
";
Now how do I convert the data in my database to a correct time/date stamp?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…