PHP code example of liliumdev / icalendar

1. Go to this page and download the library: Download liliumdev/icalendar 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/ */

    

liliumdev / icalendar example snippets




$icalobj = new ZCiCal();

$eventobj = new ZCiCalNode("VEVENT", $icalobj->curnode);

// add start date
$eventobj->addNode(new ZCiCalDataNode("DTSTART:" . ZCiCal::fromSqlDateTime("2020-01-01 12:00:00")));

// add end date
$eventobj->addNode(new ZCiCalDataNode("DTEND:" . ZCiCal::fromSqlDateTime("2020-01-01 13:00:00")));

echo $icalobj->export();

$icalobj = new ZCiCal();
$eventobj1 = new ZCiCalNode("VEVENT", $icalobj->curnode);
$eventobj1->addNode(new ZCiCalDataNode("SUMMARY:Event 1"));
...
$eventobj2 = new ZCiCalNode("VEVENT", $icalobj->curnode);
$eventobj2->addNode(new ZCiCalDataNode("SUMMARY:Event 2"));
...

$icalobj = new ZCiCal($icalstring);

$icalobj = null;
$eventcount = 0;
$maxevents = 500;
do
{
	$icalobj = newZCiCal($icalstring, $maxevents, $eventcount);
	...
	$eventcount +=$maxevents;
}
while($icalobj->countEvents() >= $eventcount);

foreach($icalobj->tree->child as $node)
{
	if($node->getName() == "VEVENT")
	{
		foreach($node->data as $key => $value)
		{
			if($key == "SUMMARY")
			{
				echo "event title: " . $value->getValues() . "\n";
			}
		}
	}
}