PHP jewishtojd() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Calendar

Definition

In PHP, jewishtojd() converts a Jewish (Hebrew) date into a Julian Day number.

It is the reverse of jdtojewish(). Once you have the Julian Day number you can pass it to jdtogregorian() to find the matching date on the normal calendar, or use it for date math.

Syntax

Call jewishtojd() with the values you need. Start with this line.

PHP
$jd = jewishtojd(4, 20, 5784);
CallWhat it does
jewishtojd(4, 20, 5784)Returns 2460311, the Julian Day for 20 Tevet 5784 (January 1, 2024).
jewishtojd(1, 1, 5784)Returns 2460204, the Julian Day for Rosh Hashanah in the year 5784.
jewishtojd(1, 1, 0)Returns 0 because year 0 is not valid.

Month numbers start at 1 for Tishri, and the Jewish year number is much higher than the Gregorian year, for example 5784. In a leap year, month 6 is Adar I and month 7 is Adar II.

Library declarations
PHP
jewishtojd(int $month, int $day, int $year): int

Parameters

ParameterDescription
monthRequired. The Jewish month number from 1 (Tishri) to 13 (Elul).
dayRequired. The day of the month from 1 to 30.
yearRequired. The Jewish year, such as 5784. It must be greater than 0.

Return Value

Return ValueDescription
intThe Julian Day number for the date. It returns 0 if the date is not valid.

PHP Examples

Example 1 — Jewish Date to Gregorian Date

Convert two Jewish dates into Julian Days, and then show the Gregorian date for each.

PHP
<?php
$jd = jewishtojd(4, 20, 5784);

echo $jd, PHP_EOL;
echo jdtogregorian($jd), PHP_EOL;

$newYear = jewishtojd(1, 1, 5784);

echo $newYear, PHP_EOL;
echo jdtogregorian($newYear), PHP_EOL;

How It Works

  1. jewishtojd(4, 20, 5784) is the 20th day of month 4 (Tevet) in the year 5784.
  2. jdtogregorian() shows that day is January 1, 2024.
  3. jewishtojd(1, 1, 5784) is the first day of Tishri, the first day of the Jewish new year.
  4. That day was September 16, 2023 on the Gregorian calendar.

Example 2 — Leap Months and Invalid Dates

The year 5784 is a leap year, so month 7 (Adar II) exists. Invalid values return 0.

PHP
<?php
$purim = jewishtojd(7, 14, 5784);

echo $purim, PHP_EOL;
echo jdtogregorian($purim), PHP_EOL;
var_dump(jewishtojd(1, 1, 0));
var_dump(jewishtojd(1, 31, 5784));

How It Works

  1. In the leap year 5784, the 14th of Adar II is month 7, day 14.
  2. The Julian Day for it is 2460394, which is March 24, 2024 in the Gregorian calendar.
  3. Year 0 is not valid, so the function returns 0.
  4. Jewish months have at most 30 days, so day 31 also returns 0.

Example 3 — How Long Is the Jewish Year?

Subtract the first day of two years to find the length of a Jewish year. Leap years are much longer.

PHP
<?php
$thisYear = jewishtojd(1, 1, 5784);
$nextYear = jewishtojd(1, 1, 5785);

echo $thisYear, PHP_EOL;
echo $nextYear, PHP_EOL;
echo 'Length: ', $nextYear - $thisYear, ' days', PHP_EOL;
echo 'Next new year: ', jdtogregorian($nextYear), PHP_EOL;

How It Works

  1. We convert the first day of Tishri for two years in a row.
  2. The difference between the two Julian Days is the length of year 5784.
  3. The year 5784 is a leap year with an extra month, so it has 383 days.
  4. The next new year, 5785, started on October 3, 2024.

Frequently Asked Questions

It converts a date in the Jewish calendar into a Julian Day number. You can then convert that number to a Gregorian date with jdtogregorian().
The order is month, day, year. The month number starts at 1 for Tishri, the first month of the Jewish year.
The year is 0 or less, the day is outside 1 to 30, or the month is not valid. Check the numbers before calling the function.
Use gregoriantojd() to get the Julian Day and then jdtojewish() to get the Jewish date. jewishtojd() goes the other way.
Yes. If PHP says jewishtojd() is undefined, enable extension=calendar in php.ini or install the php-calendar package.

Next: juliantojd()

juliantojd() converts a date in the Julian calendar into a Julian Day number.

juliantojd() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful