Create .ics file dynamically

烈酒焚心 提交于 2019-11-28 17:33:19
afuzzyllama

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!