PHP jdtojulian() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Calendar

Definition

In PHP, jdtojulian() converts a Julian Day number into a date in the Julian calendar and returns it as text in the form month/day/year.

The Julian calendar is the older calendar that the Gregorian calendar replaced. Today it is 13 days behind the Gregorian calendar. Some churches still use it for holidays like Christmas, which is why this conversion is still useful.

Syntax

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

PHP
$date = jdtojulian($jd);
CallWhat it does
jdtojulian(2451545)Returns 12/19/1999, the Julian calendar date for January 1, 2000.
jdtojulian(gregoriantojd(1, 1, 2024))Returns 12/19/2023.
jdtojulian(0)Returns 0/0/0 because the number is not a valid date.

The Julian Day number is the same in all calendars, but the date shown is different. Use jdtogregorian() on the same number to compare the two dates side by side.

Library declarations
PHP
jdtojulian(int $julian_day): string

Parameters

ParameterDescription
julian_dayRequired. The Julian Day number to convert.

Return Value

Return ValueDescription
stringThe Julian calendar date as month/day/year text. It returns 0/0/0 for a Julian Day of zero or below.

PHP Examples

Example 1 — Gregorian vs Julian Dates

Convert the same Julian Day into a Julian calendar date and compare with the Gregorian one.

PHP
<?php
echo jdtogregorian(2451545), PHP_EOL;
echo jdtojulian(2451545), PHP_EOL;

$jd = gregoriantojd(1, 1, 2024);
echo jdtogregorian($jd), PHP_EOL;
echo jdtojulian($jd), PHP_EOL;

How It Works

  1. Julian Day 2451545 is January 1, 2000 in the Gregorian calendar.
  2. In the Julian calendar the same day is December 19, 1999.
  3. The same 13-day gap shows for January 1, 2024, which is December 19, 2023 in the Julian calendar.
  4. Only the label changes, the day itself is the same.

Example 2 — The Gregorian Reform Day

In October 1582 the Gregorian calendar was introduced, and the days October 5 to 14 were skipped.

PHP
<?php
$jd = 2299161;

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

How It Works

  1. Julian Day 2299161 is the first day of the Gregorian calendar.
  2. The Julian calendar still called that day October 5, 1582.
  3. The Gregorian calendar called it October 15, which is why ten days seem to be missing.
  4. A Julian Day of 0 is not valid, so the result is 0/0/0.

Example 3 — Orthodox Christmas

Some Orthodox churches celebrate Christmas on December 25 in the Julian calendar. Find which Gregorian day that is.

PHP
<?php
$jd = gregoriantojd(1, 7, 2024);

echo 'Gregorian: ', jdtogregorian($jd), PHP_EOL;
echo 'Julian: ', jdtojulian($jd), PHP_EOL;
echo 'Weekday: ', jddayofweek($jd, CAL_DOW_LONG), PHP_EOL;

How It Works

  1. We start with January 7, 2024 in the Gregorian calendar.
  2. jdtojulian() shows that this is December 25, 2023 in the Julian calendar.
  3. So Orthodox Christmas on the Julian calendar falls on January 7 in the Gregorian calendar.
  4. jddayofweek() tells us that day was a Sunday.

Frequently Asked Questions

It converts a Julian Day number into a date in the Julian calendar and returns it as month/day/year text.
The Julian calendar is an old calendar created under Julius Caesar. A Julian Day is a plain count of days used by astronomers. PHP works with both, so the names look alike but they are different things.
The Julian calendar adds a leap day every 4 years without exception, which made its year slightly too long. The Gregorian calendar skips some leap years, and the difference has grown to 13 days.
Use juliantojd(month, day, year). It is the reverse of jdtojulian().
Yes. If jdtojulian() is undefined, enable extension=calendar in php.ini or install the php-calendar package.

Next: jdtounix()

jdtounix() converts a Julian Day number into a Unix timestamp, the number of seconds since.

jdtounix() 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