Example 1 — Convert Gregorian Dates
Turn a few ordinary dates into Julian Day numbers and convert one back.
<?php
echo gregoriantojd(1, 1, 2000), PHP_EOL;
echo gregoriantojd(1, 1, 2024), PHP_EOL;
echo gregoriantojd(12, 25, 2024), PHP_EOL;
echo jdtogregorian(gregoriantojd(1, 1, 2000)), PHP_EOL; How It Works
- Each call takes the month first, then the day, then the year.
- January 1, 2000 becomes 2451545, and January 1, 2024 becomes 2460311.
- December 25, 2024 is 359 days after January 1, 2024, so its number is 2460670.
- jdtogregorian() reverses the conversion and returns the text 1/1/2000.

