<?Php
echo gregoriantojd(12,22,2021); // Output is 2459571
echo "<br>";
echo gregoriantojd(13,22,2021); // Output is 0
echo "<br>";
echo gregoriantojd(11,32,2019); // Output is 0
echo "<br>";
echo gregoriantojd(2,30,2019); // Output is 2458545
?>
Example
int gregoriantojd ( int $month , int $day , int $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.