Asked by: Przemek Wojtas
I am bulk inserting events from ICal format to a database however what I want to is ask how to convert Ical date (20170623T080000Z) to this date format 'yyyy-mm-dd'
My other question is that each event has:
"rrule": "FREQ=MONTHLY;UNTIL=20170527T100000Z;BYDAY=4SA"
Is there a way to change existing function so that for each rrule it would take each value to a seperate variable?
So for the example above it would be:
$frequency = MONTHLY;
$until = 2017....
$day = 4SA
// Edit
I have managed to convert to an normal date, now I need to still take out unwanted parts of a string from the rrule so I have tried:
'frequency' => preg_replace($freq, $replace, $event->rrule),
but with no success
My current code:
$ical = new ICal('ical/basic.ics');
$events = ($ical->events());
$list = [];
foreach($events as $event){
$data = [
'startdate' => $event->dtstart,
'endate' => $event->dtend,
'startime' => $event->dtstart_tz,
'endtime' => $event->dtend_tz,
'title' => $event->summary,
'description' => $event->description
];
array_push($list, $data);
}
Event::insert($list);
No comments:
Post a Comment