I'm not much of a php expert and have troubles formatting the date for a .ics file.
So I have a loop that generates a calendar entry for each $post
(where a $post is an event in my case)
foreach( $posts as $post ) : setup_postdata($post);
$ical .= "BEGIN:VEVENT
UID:" . md5(uniqid(mt_rand(), true)) . "mysite.com
DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
DTSTART:".get_event_date($post)."00Z
DTEND:".get_event_end_date($post)."00Z
SUMMARY:".get_the_title($post->ID)."
DESCRIPTION:".get_the_excerpt($post->ID)."
END:VEVENT";
endforeach;
I have just problems with formatting the date that's why I got completey rid of it and hope you guys might help me.
I have two functions get_event_date($post)
and get_event_end_date($post)
that return a timestamp like 1258665163
. How can I convert this timestamp into the right format for the iCal .ics file?
Moreover I'd also like to add the time
of each event.
Those two function are called get_event_time($post)
and get_event_end_time($post)
which both return a time in the following format: 11:00
or 14:00
Can somebody help me out here? I'd really appreciate some help.
Basically you want to convert a unix timestamp to the format specified for iCal.
There's a wonderful little comment in the php manual regarding the date function which includes this little jewel, doing exactly that:
Maybe this helps.