How to Convert Jewish Date to Julian Date in PHP
As a developer, you might come across a situation where you need to convert a Jewish date to a Julian date. This can be a challenging task as the Jewish
PHP's jewishtojd() function converts a date in the Jewish (Hebrew) calendar into a Julian Day Count — a single integer that uniquely identifies a day. Because Julian Day Counts are calendar-neutral, they act as a common "pivot" that lets you convert between calendar systems: convert a Jewish date to a Julian Day, then convert that number into a Gregorian date (or any other supported calendar). This page explains how the function works, its parameters and edge cases, and shows verified, runnable examples.
The Calendar functions require the
calendarPHP extension. It ships with most builds and is enabled by default on Windows; on Linux you may need to compile PHP--with-calendaror install a package such asphp-calendar.
What is a Julian Day Count?
A Julian Day Count (JDN) is the number of days that have elapsed since noon (UTC) on January 1, 4713 BCE in the proleptic Julian calendar. Do not confuse it with the Julian calendar — despite the shared name, the Julian Day Count is just a continuous day counter with no months or years.
JDN is the bridge format for PHP's calendar extension. Every *tojd() function (jewishtojd(), gregoriantojd(), juliantojd(), frenchtojd()) produces a JDN, and every jdto*() function consumes one. So all cross-calendar conversion flows through it:
Jewish date ──jewishtojd()──▶ JDN ──jdtogregorian()──▶ Gregorian dateFunction signature
jewishtojd(int $month, int $day, int $year): int| Parameter | Description |
|---|---|
$month | Jewish month number where 1 = Tishri, not January (see the gotcha below). Valid range is 1–13. |
$day | Day of the month, 1–30. |
$year | Jewish year, counted from the traditional date of creation (year 1 ≈ 3761 BCE). |
It returns the Julian Day Count as an integer, or 0 for a date outside the supported range (years roughly 1 to 9999).
Gotcha: month numbering starts at Tishri
This is the single most common mistake with jewishtojd(). The Jewish religious year begins in spring (Nisan), but PHP numbers the months starting from Tishri (the civil new year, Rosh Hashanah). So:
| # | Month (non-leap year) |
|---|---|
| 1 | Tishri |
| 2 | Heshvan |
| 3 | Kislev |
| 4 | Tevet |
| 5 | Shevat |
| 6 | Adar |
| 7 | Adar (same as 6 in a non-leap year) |
| 8 | Nisan |
| 9 | Iyyar |
| 10 | Sivan |
| 11 | Tammuz |
| 12 | Av |
| 13 | Elul |
In a leap year an extra month is inserted: month 6 becomes Adar I and month 7 becomes Adar II. Passing 6 does not mean June or Sivan — Sivan is month 10.
Basic example
This converts 6 Sivan 5783 (the festival of Shavuot, which is the 10th month, day 6) to its Julian Day Count, then back to a Gregorian date so you can sanity-check it:
Converting a Jewish date to a Julian Day Count
<?php
$jewishMonth = 10; // Sivan
$jewishDay = 6;
$jewishYear = 5783;
$jdn = jewishtojd($jewishMonth, $jewishDay, $jewishYear);
echo "Julian Day Count: " . $jdn . "\n";
echo "Gregorian date: " . jdtogregorian($jdn) . "\n";Output:
Julian Day Count: 2460091
Gregorian date: 5/26/2023So 6 Sivan 5783 falls on 26 May 2023 in the Gregorian calendar.
Converting a Jewish date to Gregorian
Pairing jewishtojd() with jdtogregorian() is the typical real-world use case — for example, finding the Gregorian date of Rosh Hashanah (1 Tishri):
<?php
function jewishToGregorian(int $month, int $day, int $year): string
{
$jdn = jewishtojd($month, $day, $year);
if ($jdn === 0) {
return "Invalid Jewish date";
}
return jdtogregorian($jdn);
}
echo jewishToGregorian(1, 1, 5784) . "\n"; // Rosh Hashanah 5784Output:
9/16/2023Round-tripping with jdtojewish()
The inverse of jewishtojd() is jdtojewish(), which turns a Julian Day Count back into a month/day/year Jewish date string. Round-tripping is a good way to confirm your month numbering is right:
<?php
$jdn = jewishtojd(10, 6, 5783); // 6 Sivan 5783
echo "JDN: " . $jdn . "\n";
echo "Jewish: " . jdtojewish($jdn) . "\n"; // month/day/yearOutput:
JDN: 2460091
Jewish: 10/6/5783Handling invalid input
For a date PHP can't represent, jewishtojd() returns 0 rather than throwing an error, so always guard against it before passing the result to another function:
<?php
$jdn = jewishtojd(0, 5, 5783); // month 0 is invalid
var_dump($jdn); // int(0)
echo $jdn === 0 ? "Out of range\n" : jdtogregorian($jdn) . "\n";Output:
int(0)
Out of rangeWhen would I use this?
- Displaying Hebrew/holiday dates from a database in the user's local Gregorian calendar.
- Computing the number of days between two dates given in different calendar systems (subtract their JDNs).
- Finding the day of the week for a Jewish date by feeding the JDN to
jddayofweek().
Conclusion
jewishtojd() converts a Jewish (Hebrew) calendar date into a Julian Day Count, the calendar-neutral integer that PHP's calendar extension uses as a pivot for all cross-calendar conversions. The two things to remember are that month numbering starts at Tishri (1), not Nisan, and that the function returns 0 for out-of-range dates. Combine it with jdtogregorian(), jdtojewish(), or jddayofweek() to build complete date workflows.