www.webdeveloper.com
Results 1 to 3 of 3

Thread: Dumping MySQL to .ical files

  1. #1
    Join Date
    Aug 2008
    Posts
    3

    Dumping MySQL to .ics calendar 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
    Last edited by hollywoodjrc; 08-10-2008 at 12:12 AM.

  2. #2
    Join Date
    Jun 2006
    Posts
    117
    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.
    Last edited by drhart4000; 08-12-2008 at 10:39 PM.

  3. #3
    Join Date
    Jun 2006
    Posts
    117
    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
    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
    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-icale...files-with-php
    Last edited by drhart4000; 08-12-2008 at 10:44 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles