Brilliantly clever PHP calendar class
Switch branches/tags
Nothing to show
Latest commit 832f240 Apr 10, 2012 @jamierumbelow Merge pull request #1 from AnthonySterling/patch-1
Incorrect array addressing in readme. :)
Failed to load latest commit information.
libraries Updated the documentation and changed protected _setup() to public se… Jan 14, 2012


Julian is a very clever, standalone PHP calendar class, with support for events, fully customisable templates and totally arbitrary URLs.



Copy the download directory into your project. Require the libraries/julian.php file into your script, ensure you're linking the stylesheets into your views and away you go.

Julian was built and tested inside CodeIgniter. Copying the contents of libraries into your application/libraries folder will allow you to load Julian like any other CodeIgniter library.

Example Controller

require_once 'libraries/julian.php';

$year = @$_GET['year'] ?: date('Y');
$month = @$_GET['month'] ?: date('m');

$calendar = new Julian(array(
    'url'           => site_url('/absence_requests?year=%y&month=%m'),
    'current_month' => $month,
    'current_year'  => $year

Example View

<link href="/stylesheets/bootstrap.min.css" rel="stylesheet" />
<link href="/stylesheets/julian.css" rel="stylesheet" />

<div id="calendar">
    <div id="calendar_header" class="alert-message block-message">
        <div class="span5"><?= anchor($calendar->prev_url(), "&lt;&lt;") ?></a></div>
        <div class="span6"><?= $calendar->current_month() ?> <?= $calendar->current_year() ?></div>
        <div class="span5"><?= anchor($calendar->next_url(), "&gt;&gt;") ?></a></div>
    <table class="bordered-table zebra-striped">
            <?php foreach ($calendar->weekdays() as $weekday): ?>
                <td><?= $weekday ?></td>
            <?php endforeach ?>
        <?php foreach ($calendar->weeks() as $week): ?>
                <?php foreach ($week->days() as $day): ?>
                    <td class="calendar-day <?= $day->today_class() ?>">
                        <?php if(!$day->blank()): ?>
                            <span class="day-number"><?= $day->day() ?></span>
                        <?php endif; ?>
                <?php endforeach; ?>
        <?php endforeach; ?>
    <table id="calendar-event-overlay">
        <?php foreach($calendar->weeks() as $week): ?>
                <?php foreach ($week->days() as $day): ?>
                    <td class="calendar-day">
                        <?php if(!$day->blank()): ?>
                            <?php foreach($day->events() as $event): ?>
                                <div class="calendar-event <?= $event->class_name() ?>">
                                    <?= $event->name() ?>
                            <?php endforeach; ?>
                        <?php endif; ?>
                <?php endforeach; ?>
        <?php endforeach; ?>


An Example Calendar


Passing through an array of config values to the constructor has the same effect as calling initialize() directly, or by setting the instance variables on an instance. Right now, Julian is very beta, so the range of config values is fairly limited. Nonetheless, here's a list of the existing values and what they do.

  • $current_month - Sets the currently displayed month. Should be in format MM.
  • $current_year - Sets the currently displayed year. Should be in format YYYY.

Changing either of these values will require recalculation, so you should ensure that you call setup() or set the values through initialize().

  • $url - A template for generating the previous/next URLs using the prev_url() and next_url() methods. %y and %m will be replaced with the appropriate year and month, respectively.

Why Julian?

Julian takes its namesake from two places. Firstly, the Julian Calendar, introduced by Julius Caesar in 46BC, and secondly, one of my closest friends, fellow web developer @juliancheal.