Fork me on Github


The missing PHP5.3+ calendar management library


 $ curl -s | php
 $ php composer.phar require yohang/calendr
View on Github

Simple calendar generation

// Use the factory to get your period
$factory = new CalendR\Calendar;
$month = $factory->getMonth(2012, 01);

    <?php // Iterate over your month and get weeks ?>
    <?php foreach ($month as $week): ?>
        <?php // Iterate over your month and get days ?>
        <?php foreach ($week as $day): ?>
            <?php //Check days that are out of your month ?>
            <td><?php echo $day ?></td>
        <?php endforeach ?>
    <?php endforeach ?>


$month = $factory->getMonth(2012, 6)

// Retrieve an event collection from the event manager
$events = $factory->getEvents($month)

<?php foreach ($month as $week): ?>
    <h2>Week #<?php echo $week ?></h2>
        <?php // retrieve events for the subperiod (week) ?>
        <?php foreach ($events->find($week) as $event): ?>
            <li><?php echo $event ?></li>
        <?php endforeach ?>
<?php endforeach ?>