W3docs

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 calendar PHP extension. It ships with most builds and is enabled by default on Windows; on Linux you may need to compile PHP --with-calendar or install a package such as php-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 date

Function signature

jewishtojd(int $month, int $day, int $year): int
ParameterDescription
$monthJewish month number where 1 = Tishri, not January (see the gotcha below). Valid range is 1–13.
$dayDay of the month, 1–30.
$yearJewish 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)
1Tishri
2Heshvan
3Kislev
4Tevet
5Shevat
6Adar
7Adar (same as 6 in a non-leap year)
8Nisan
9Iyyar
10Sivan
11Tammuz
12Av
13Elul

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/2023

So 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 5784

Output:

9/16/2023

Round-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/year

Output:

JDN:    2460091
Jewish: 10/6/5783

Handling 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 range

When 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.

Practice

Practice
What is the function of the jewishtojd() function in PHP?
What is the function of the jewishtojd() function in PHP?
Was this page helpful?