开发者

Populating a calendar based on RSS feeds

I am trying to build a calendar in php which will display events on my website. My requirement is to populate the calendar with events from different websites, which publish an RSS feeds of their events.

In my initial attempt I parsed the events based on the <pubDate> tag and aggregated those in my calendar. However, I soon realized that this doesn't work the way I want it to.

The problem lies in the fact that the RSS feeds from different websites are not consistent with each other. For eg. One of the sites published the date for the event in th开发者_运维技巧e <pubDate> tag as <pubDate>Mon, 25 Jul 2011 21:11:40 GMT</pubDate>.

Another one has it in the <title> tag - as <title>26 Sep 2011 19:00 : The Life of a Lily</title>.

One other site has the event date in the <Description> tag as free floating text.

I am really in a fix as to how to consolidate these into a single calendar. Can someone please suggest a way I can do this? Or am I left with just cursing how non-standard the feeds are, in-spite of being technically standard?

Thanks a lot!


First you would need to locate and parse out the date portion of the posts. You could do this using regex or with PHP's string functions. Then you could use PHP's strtotime(..) and date(..) to normalize the dates, like this:

$date = '26 Sep 2011 19:00';
print date("Y-m-d", strtotime($date)); // prints: 2011-09-26
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜