gregoriantojd()

Convert a Gregorian date to a Julian Day

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);
}
?>
For Gregorian user input, validate with checkdate() before conversion. gregoriantojd() can normalize overflowing day values rather than acting as a strict date validator.
Syntax
gregoriantojd($month, $day, $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


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-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer