1. Go to this page and download the library: Download om/icalparser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
om / icalparser example snippets
use om\ICal;
$calendar = ICal::parseFile('calendar.ics'); // or ICal::parse($content)
foreach ($calendar->events() as $event) {
echo $event->summary(), ' ', $event->start()?->format('Y-m-d H:i'), PHP_EOL;
}
// every instance of every event in a period, sorted, with moved and cancelled instances applied
$from = new DateTimeImmutable('2026-01-01');
$to = new DateTimeImmutable('2026-02-01');
foreach ($calendar->occurrencesBetween($from, $to) as $occurrence) {
// the local time; ->startTime($timezone) gives an instant (see "Dates and times")
printf("%s %s%s\n", $occurrence->start->format('j. n. H:i'), $occurrence->summary(), $occurrence->isModified() ? ' (changed)' : '');
}
$event->property('X-APPLE-STRUCTURED-LOCATION')?->parameter('X-TITLE');
$event->value('X-MICROSOFT-CDO-BUSYSTATUS'); // the typed value
$start = $event->start();
$start->format('Y-m-d H:i'); // the local value, always
$start->toDateTime(); // the instant; needs a timezone for dates and floating times
$start->toDateTime(new DateTimeZone('Europe/Prague')); // in a given timezone
$start->isDate(); $start->isFloating(); $start->isUtc(); $start->isZoned();
foreach ($event->occurrencesBetween($from, $to) as $occurrence) { /* ... */ }
foreach ($event->occurrences(limit: 10) as $occurrence) { /* ... */ }
use om\RRule\Expander;
use om\RRule\Rule;
$rule = Rule::fromString('FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1;COUNT=3'); // the last workday
foreach (new Expander($rule, new DateTimeImmutable('2026-01-30 09:00', new DateTimeZone('Europe/Prague'))) as $timestamp) {
echo date('Y-m-d', $timestamp), PHP_EOL;
}
use om\ICal\Parser\ParserMode;
$result = ICal::parser()->mode(ParserMode::Permissive)->parseFile('feed.ics');
$calendar = $result->calendar();
foreach ($result->warnings() as $warning) {
echo $warning, PHP_EOL; // line 12: END:VEVENT is missing, the component was closed. [syntax.missing-end]
}
foreach (ICal::stream('huge.ics') as $item) { // events, tasks, ... one by one, constant memory
echo $item->summary(), PHP_EOL;
}
use om\ICal\Alarm;
use om\ICal\Calendar;
use om\ICal\Event;
use om\ICal\Value\CalAddress;
$calendar = Calendar::create('-//example//standup//EN', name: 'Team A', events: [
Event::new(
summary: 'Standup, team A',
start: new DateTimeImmutable('2026-01-05 09:30', new DateTimeZone('Europe/Prague')),
duration: new DateInterval('PT15M'),
rrule: 'FREQ=WEEKLY;BYDAY=MO,WE,FR',
attendees: [CalAddress::create('mailto:[email protected]', name: 'A', rsvp: true)],
alarms: [Alarm::display('Standup', trigger: '-PT5M')],
),
]);
echo $calendar->serialize(); // or $calendar->writeFile('team.ics')
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.