gregoriantojd() converts Gregorian month, day and year values to a Julian Day count.
$jd = gregoriantojd(9, 14, 2026);
echo $jd;<?php
$month = 2;
$day = 29;
$year = 2024;
if (checkdate($month, $day, $year)) {
echo gregoriantojd($month, $day, $year);
}
?>
checkdate() before conversion. gregoriantojd() can normalize overflowing day values rather than acting as a strict date validator.gregoriantojd($month, $day, $year)
| Parameter | DESCRIPTION |
|---|---|
| $year | Required : Year in four digits between -4714 and 9999 |
| $day | Required : between 1 to 31 |
| $month | Required : Number from 1 to 12 |
$jd = gregoriantojd(2, 29, 2020); // Leap year date
echo "Julian Day: " . $jd; // Output: Julian Day number for Feb 29, 2020
if (checkdate(2, 29, 2021)) {
$jd = gregoriantojd(2, 29, 2021);
echo "Julian Day: " . $jd;
} else {
echo "Invalid date";
}
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.