PHPackages                             tinuviel/php-ics - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. tinuviel/php-ics

ActiveLibrary

tinuviel/php-ics
================

Generate a iCalendar (.ics) file in PHP.

0.3.0(8y ago)015MITPHPPHP ^5.3 || ^7.0

Since Nov 24Pushed 8y agoCompare

[ Source](https://github.com/Bonno/php-ics)[ Packagist](https://packagist.org/packages/tinuviel/php-ics)[ Docs](https://github.com/Bonno/php-ics)[ RSS](/packages/tinuviel-php-ics/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

PHP to ICS
==========

[](#php-to-ics)

This gist contains a convenient script to generate iCalendar (.ics) files on the fly in PHP.

Basic usage
-----------

[](#basic-usage)

```
include 'ICS.php'

$properties = array(
  'dtstart' => 'now',
  'dtend' => 'now + 30 minutes'
);

$ics = new ICS($properties);
$ics_file_contents = $ics->to_string();
```

### Available properties

[](#available-properties)

- **description** - string description of the event.
- **dtend** - date/time stamp designating the end of the event. You can use either a `DateTime` object or a [PHP datetime format string](http://php.net/manual/en/datetime.formats.php) (e.g. "now + 1 hour").
- **dtstart** - date/time stamp designating the start of the event. You can use either a `DateTime` object or a [PHP datetime format string](http://php.net/manual/en/datetime.formats.php) (e.g. "now + 1 hour").
- **location** - string address or description of the location of the event.
- **summary** - string short summary of the event - usually used as the title.
- **url** - string url to attach to the the event. Make sure to add the protocol (`http://` or `https://`).

Detailed examples
-----------------

[](#detailed-examples)

### Button that downloads an ICS file when clicked

[](#button-that-downloads-an-ics-file-when-clicked)

This example contains a form on the front-end that submits to a PHP script that initiates a download of an ICS file. This example uses hidden form fields to set the properties dynamically.

**index.html**

```

```

**download-ics.php**

```
