/    Sign up×
Community /Pin to ProfileBookmark

Dumping MySQL to .ical files

Good evening,
We currently have a large event/calendar repository on our web site, which was programmed in-house. We are interested in dumping these events into .ics files on our public web site, so people can import into their MS Outlook, Google Calendar, iCalendar, etc.

Ideally, I was hoping that we could create these dynamically through PHP on each event details page… I’m just not sure how we can do this 🙂

Does anyone know what would be required to perform such a task? Since I understand this may be a very broad question, if anyone could at least point me in the right direction I’d greatly appreciate the help!

Thank you,
JR

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@drhart4000Aug 13.2008 — I'm looking into this for you, I just need to see how .ics files are formatted and I think I can give you a push in the right direction.
Copy linkTweet thisAlerts:
@drhart4000Aug 13.2008 — Ok, here's what I've found. It will be some what simple to program.

a very basic ics file looks like this:
[CODE]BEGIN:VCALENDAR
PRODID:TestCal
X-WR-CALNAME:TestCal
X-WR-CALDESC:TestCal
VERSION:2.0
CALSCALE:GREGORIAN

BEGIN:VEVENT
DTSTART:20080819
DTEND:20080819
LOCATION:Location
UID:2
URL:http://mydomain.com
DESCRIPTION:Put a description here :D
SUMMARY:Title here
END:VEVENT

END:VCALENDAR[/CODE]

This file has a simple 1 day long event for 08-19-2008.

to make the file in this manner it would require knowing the date start, date end, location, url(optional), description, and summery. Just pull this data from the mysql server and put it in the variables needed, then loop through all your events and make the file dynamically.


------------------------
Now when it comes to specific times it gets a little more in depth... as you need to tell the software what time zone you are referring to when specifying times. an example of the same file but with the time from 12am to 1am is here:
[CODE]BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Windows Calendar 1.0//EN
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Central Time (US & Canada)
BEGIN:STANDARD
DTSTART:20001029T020000
RRULE:FREQ=YEARLY;UNTIL=20061029T080000Z;BYDAY=-1SU;BYMONTH=10
TZNAME:Central Standard Time
TZOFFSETFROM:-0500
TZOFFSETTO:-0600
END:STANDARD
BEGIN:STANDARD
DTSTART:20071104T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
TZNAME:Central Standard Time
TZOFFSETFROM:-0500
TZOFFSETTO:-0600
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20000402T020000
RRULE:FREQ=YEARLY;UNTIL=20060402T080000Z;BYDAY=1SU;BYMONTH=4
TZNAME:Central Daylight Time
TZOFFSETFROM:-0600
TZOFFSETTO:-0500
END:DAYLIGHT
BEGIN:DAYLIGHT
DTSTART:20070311T020000
RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
TZNAME:Central Daylight Time
TZOFFSETFROM:-0600
TZOFFSETTO:-0500
END:DAYLIGHT
END:VTIMEZONE

BEGIN:VEVENT
DESCRIPTION:Put a description here :D
DTSTART;TZID=Central Time (US & Canada):20080819T000000
DTEND;TZID=Central Time (US & Canada):20080819T010000
LOCATION:Location
SUMMARY:Title here
UID:2
URL:http://mydomain.com
END:VEVENT

X-WR-CALNAME:TestCal
X-WR-CALDESC:TestCal
END:VCALENDAR
[/CODE]


This is going to take a little bit of work in php but it can be done fairly easily.

This should give you a great start: http://bradym.net/php/creating-icalendar-ics-files-with-php
×

Success!

Help @hollywoodjrc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...