Convert microformats h-event to iCalendar
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src/GregorMorrill/Mf2toiCal Bump version to 0.0.2 Mar 30, 2018
tests Add unit tests Mar 30, 2018 Update README Mar 30, 2018
composer.json Add unit tests Mar 30, 2018
phpunit.xml Add unit tests Mar 30, 2018


Convert microformats h-event to iCalendar.

Note: This is currently very much an alpha version, doing the minimal amount I needed it to do. I plan to expand it, though. Issue reports are welcomed.



It is recommended to install via Composer. This project is not listed on packagist yet, but will be once it's more stable. Until then, you can install by adding to your composer.json:

    "repositories": [
            "type": "vcs",
            "url": ""
    "require": {
        "gregorlove/mf2-to-icalendar": "dev-master"

Then in the project file you want to use it, import the namespace and add the Composer autoloader:

use GregorMorrill\Mf2toiCal;


Manual Installation

Alternately, you can manually install without using Composer.

You will need to first download the php-mf2 and php-mf-cleaner libraries linked above and include them in your project.

Then download the files in this project's directory src/GregorMorrill/Mf2toiCal/ and include them directly in your project:

use GregorMorrill\Mf2toiCal;


Specify the Domain

The generated iCalendar .ics file has a PRODID that includes a domain and the name/version of this script.

It's recommended to specify the domain you're using this on. If you don't, it will default to domain,

To specify your domain, after installation define the constant:

define('PRODID_DOMAIN', '');


catch ( Exception $e )
	echo $e->getMessage();


If the specified URL does not have h-event microformats, an Exception is thrown. Your code should be set up to handle that Exception.

Language and Character Set

This script defaults to language en and charset utf-8 for text content lines in the generated .ics file. You can specify different options when calling convert():

# parameters: $url, $lang, $charset
Mf2toiCal\convert('', 'sv');

Detecting the language from the HTML and using that is on my TODO list.




  • Now prefers content h-event property over description
  • Adds support for dates with local time
  • Adds unit tests



  • initial release