gregoriantojd()

<?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 )
ParameterDESCRIPTION
$yearRequired : Year in four digits between -4714 and 9999
$dayRequired : between 1 to 31
$monthRequired : Number from 1 to 12
Output is The julian day for the given gregorian date as an integer.

Example: Converting Leap Year Date

$jd = gregoriantojd(2, 29, 2020);  // Leap year date
echo "Julian Day: " . $jd;  // Output: Julian Day number for Feb 29, 2020

Example: Validating Date Before Conversion

More on checkdate()
if (checkdate(2, 29, 2021)) {
    $jd = gregoriantojd(2, 29, 2021);
    echo "Julian Day: " . $jd;
} else {
    echo "Invalid date";
}

Information about available Calendars
Calendar Functions
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer