PHP code example of bvanhoekelen / icalendar-php
1. Go to this page and download the library: Download bvanhoekelen/icalendar-php 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/ */
bvanhoekelen / icalendar-php example snippets
alendar\Element\Calendar;
use Calendar\Type\Location;
use Calendar\Type\Geo;
$calender = (new Calendar())
->setColor('#00A677')
->setName('Custom name')
->setDescription('Custom description')
->setRefreshInterval('P1H')
;
// Add Event
$calender->newEvent()
->setDtStart(new DateTime('now'))
->setDtEnd(new DateTime('+1 day'))
->setDtStamp(new DateTime('now'))
->setSummary('short summary of the event')
->setDescription('full description of the event')
->setUrl('https://www.google.nl')
// Add Location
->setLocationWizard(((new Location())
->setTitle('Koninklijk Paleis Amsterdam')
->setStreetAddress('Nieuwezijds Voorburgwal 147')
->setZipCode('1012 RJ')
->setCity('Amsterdam')
->setCountry('Nederland')
->setGeo(new Geo(52.373149,4.891342))
))
// Add organizer
->setOrganizerWizard('Bart', '[email protected]')
// Add attended
->setAttendee((new Attendee())
->wizard(Attendee::PARTSTAT_ACCEPTED, 'Bart', '[email protected]')
)
->setAttendee((new Attendee())
->wizard(Attendee::PARTSTAT_ACCEPTED, 'Henk', '[email protected]')
)
// Add repeat
->setRepeatRule((new RepeatRule(RepeatRule::FREQ_YEARLY))
->setByDay(RepeatRule::BYDAY_TH)
->setBySetPos(RepeatRule::BYSETPOS_FIRST)
->setByMonth(RepeatRule::BYMONTH_NOV)
->setCount(7)
)
;
// Render to string with headers
echo $calender->serve();
composer