Preferences Language:

Method:

Sefirat HaOmer:

Holiday Eves:

Isru Khags:

SunMonTueWedThuFriSat
1 22 2 23 3 24 4 25
5 26 6 27 7 28 8 29
Erev Rosh HaShana
9 1 (Tishrei)
Rosh HaShana I
10 2
Rosh HaShana II
11 3
12 4
Tsom Gedalya
13 5 14 6 15 7 16 8 17 9
Erev Yom Kippur
18 10
Yom Kippur
19 11 20 12 21 13 22 14
Erev Sukkot
23 15
Sukkot
24 16
Sukkot II (Diaspora)
25 17
Khol HaMoed Sukkot
26 18
Khol HaMoed Sukkot
27 19
Khol HaMoed Sukkot
28 20
Khol HaMoed Sukkot
29 21
Hoshana Rabba
30 22
Shemini Atseret

iCal feed

The Source Code

You may download the source code and use it on your website. It's GPLed.

The API

The most important part of the code is the JewishCalendar PHP class. It contains the 'brain' that calculates the holidays. It is derived from the base class NativeCalendar, so you should add also this to the bundle. The rest of the code, including the GUI you see here, is considered a demonstration of how to use this class and is appropriately contained in files having 'demo' in their names (e.g. 'demo.php').

Here's a taste of the API:

require_once 'NativeCalendar.php';

$jcal = NativeCalendar::factory('Jewish'); // In the future there may be Drivers
                                           // for other calendars.

$jcal->settings(array(
  'language' => CAL_LANG_NATIVE, // Speak in Hebrew, not English.
  'diaspora' => FALSE,           // We don't live abroad.
  'eves'     => TRUE,            // Give us 'Erev Rosh HaShana' too.
));

// Let's print the holidays for the next 20 days.

$timestamp = time();

for ($n = 20; $n--; ) {
  print 'Holidays for '. date('Y-m-d', $timestamp) .":\n";
  foreach ($jcal->getHolidays($timestamp) as $holiday) {
    print "   $holiday[name]\n";
  } 
  $timestamp += 60*60*24; // Advance to the next day
}

The output of this snippet is:

Holidays for 2007-09-20:
Holidays for 2007-09-21:
   ערב יום הכיפורים
Holidays for 2007-09-22:
   יום הכיפורים
Holidays for 2007-09-23:
Holidays for 2007-09-24:
Holidays for 2007-09-25:
Holidays for 2007-09-26:
   ערב סוכות
Holidays for 2007-09-27:
   סוכות
Holidays for 2007-09-28:
   חול המועד סוכות
Holidays for 2007-09-29:
   חול המועד סוכות
Holidays for 2007-09-30:
   חול המועד סוכות
Holidays for 2007-10-01:
   חול המועד סוכות
Holidays for 2007-10-02:
   חול המועד סוכות
Holidays for 2007-10-03:
   הושענא רבה
Holidays for 2007-10-04:
   שמיני עצרת
‎   שמחת תורה
Holidays for 2007-10-05:
Holidays for 2007-10-06:
Holidays for 2007-10-07:
Holidays for 2007-10-08:
Holidays for 2007-10-09:

Let's have another script...

// Print today's date:
print $jcal->getLongDate(time()) ."\n";

// Now in English:
$jcal->settings(array('language' => CAL_LANG_FOREIGN));
print $jcal->getLongDate(time()) ."\n";

// When did the first man land on the moon?
print $jcal->getLongDate('1969-07-20') ."\n";

...which outputs:

ח' תשרי ה'תשס"ח
8 Tishrei, 5768
5 Av, 5729

Localization

The calendar comes speaking in two languages: Hebrew and English. But you can make it speak any other language. This is due to the fact that all English strings --month names and holiday names-- are enveloped in a special function. Mavens will recognize this as "the Gettext method of localizing strings." I chose the name 't' for this function.

In some projects you'd use various gettext tools to extract (see JewishCalendar.pot) and translate the strings, but it's actually sufficient to implement a simple-minded t() function in your script. Here's an example:

require 'NativeCalendar.php';

$jcal = NativeCalendar::factory('Jewish'); // In da future they may be drivers
                                           // fo otha calendars.
$jcal->settings(array(
  'language' => CAL_LANG_FOREIGN,
  'diaspora' => TRUE,
));

function t($s) {
  static $table = array(
    'Tishrei' => 'Teeshre',
    'Erev Rosh HaShana' => 'Justa little bit before da start of da year.',
    'Rosh HaShana I' => 'Da start of da year.',
    'Rosh HaShana II' => 'Anotha start of da year, man. See? There be two.',
    'Yom Kippur' => "Da 'No TV' day.",
    'Tsom Gedalya' => 'Rememba poor Gedalya, OK?',
    'Sukkot' => "You's squizin' yo' TV inside this thingy a here.",
  );
  if (isset($table[$s])) {
    return $table[$s];
  } else {
    return $s;
  }
}

// Dig dis:
print $jcal->printCal(2007, 9);