gregoriantojdGETS the
Julian Day Number, (JDN) for a date in the
Gregorian Calendar.
<?php
int gregoriantojd ( int $month , int $day , int $year )
where,
$month = The month number
$day = The day number.
$year = The year number
?>
$month
The month number.
$day
The day number.
$year
The year number.
Julian Day Number, (JDN) also known as Julian Day Count, (JDC), indicates the number of days elapsed since January 1, 4713 BC, Gregorian Calendar.
The Julian Calendar was introduced by Júlio Cesar in 46 BC, according the Gregorian Calendar.
The valid range for the Gregorian Calendar is from November 25, 4714 BC to at least December 31, 9999 AD.
Although this function can handle dates all the way back to 4714 BC, such use may not be meaningful.
The Gregorian Calendar was not instituted until October 15, 1582, (or October 5, 1582 in the Julian Calendar).
Some countries did not accept it until much later.
For example, Britain converted in 1752, The USSR in 1918 and Greece in 1923.
Most European countries used the Julian Calendar prior to the Gregorian.
The $month is expressed as a number from 1, (January), to 12, (December).
The $day is a number from 1 to 31.
If $day has less of the given $month, an overflow occurs.
The $year must be represented by a number between -4714 and 9999.
Negative values mean BC years, positive AD.
Note that there is no year ZERO.
The positive value begin in the year 1 AD.
This function can be considered inverse to the function jdtogregorian.
EXERCISE
<?php
$now01 = microtime(1);
$month01 = idate('m', $now01);
$day01 = idate('d', $now01);
$year01 = idate('Y', $now01);
$gregtojdc01 = gregoriantojd($month01, $day01, $year01);
echo $month01 . '-' . $day01 . '-' . $year01 . '<sub>(month-day-year) Gregorian</sub> => ' . $gregtojdc01 . '<sub>JDN</sub>';
?>
EXERCISE
<?php
$lctm02 = localtime(time(), TRUE);
$m02 = ($lctm02['tm_mon'] + 1);
$d02 = ($lctm02['tm_mday']);
$y02 = ($lctm02['tm_year'] + 1900);
$gregtojdc02 = gregoriantojd($m02, $d02, $y02);
echo $m02 . '-' . $d02 . '-' . $y02 . '<sub>(month-day-year) Gregorian</sub> => ' . $gregtojdc02 . '<sub>JDN</sub>';
?>
EXERCISE
<?php
$date03 = '08/03/1945 08:03+03:00';
$arrdp03 = date_parse_from_format("d/m/Y H:iP", $date03);
$y03 = $arrdp03['year'];
$m03 = $arrdp03['month'];
$d03 = $arrdp03['day'];
$gregtojdc03 = gregoriantojd($m03, $d03, $y03);
echo $m03 . '-' . $d03 . '-' . $y03 . '<sub>(month/day/year) Gregorian</sub> => ' .
$gregtojdc03 . '<sub>JDN</sub>';
?>