Create .ics file dynamically

前端 未结 1 1100
暗喜
暗喜 2020-12-13 04:53

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

相关标签:
1条回答
  • 2020-12-13 05:23

    iCal times stored in UTC and not in the time zone that they originated in unless otherwise specified (see edit)

    If you want your code to be generic, you'll need to store the time zone as well. If you really want to... you can hard code in the conversion.

    I would also recommend not storing time in this format:

     Month: 05
     Day: 02 
     Year: 2011
     Time: 11:30am - 1:30pm
    

    and move to a timestamp format. You'll go from 4(?) columns down to one. Why is this good? Because you can use PHP date() to format the date for you into exactly what you need! (you'll need to use strtotime() I believe and also someone has a timezone conversion function in the comments)

    Looking at what needs to be done from an iCal perspective:

     echo "DTSTAMP:<year><month><day>T<hour><minutes><seconds>Z\n";  // Time iCal item was made
     echo "DTSTART:<year><month><day>T<hour><minutes><seconds>Z\n";  // Start time
     echo "DTEND:<year><month><day>T<hour><minutes><seconds>Z\n";    // End time
    

    EDIT:
    The Z represents UTC time, or absolute time.
    You can set the timezone in the file and leave the conversion to the calendar program.
    http://tools.ietf.org/html/rfc5545#section-3.2.19

    0 讨论(0)
提交回复
热议问题