Is it possible this function is incorrect? According to Numerical Recipes in Pascal (ISBN 0521375169), 5/23/1968 should have a Julian Date of 2440000. Instead, the value returned by the PHP function is 2440013. An online converter such as http://www.onlineconversion.com/julian_date.htm e.g. confirms this. FYI, I ported the NR function to PHP as follows:
function julday($mm, $id, $iyyy) {
$igreg=588829;
if ($iyyy == 0) {
echo 'there is no year zero.';
return null;
}
if ($iyyy < 0) $iyyy = $iyyy+1;
if ($mm > 2) {
$jy = $iyyy;
$jm = $mm+1;
} else {
$jy = $iyyy-1;
$jm = $mm+13;
}
$jul = floor(365.25*$jy)+floor(30.6001*$jm)+$id+1720995;
if ($id+31*($mm+12*$iyyy) >= $igreg) {
$ja = floor(0.01*$jy);
$jul = $jul+2-$ja+floor(0.25*$ja);
}
return $jul;
}
JulianToJD
(PHP 4, PHP 5)
JulianToJD — Converts a Julian Calendar date to Julian Day Count
Description
Valid Range for Julian Calendar 4713 B.C. to 9999 A.D.
Although this function can handle dates all the way back to 4713 B.C., such use may not be meaningful. The calendar was created in 46 B.C., but the details did not stabilize until at least 8 A.D., and perhaps as late at the 4th century. Also, the beginning of a year varied from one culture to another - not all accepted January as the first month.
Remember, the current calendar system being used worldwide is the Gregorian calendar. gregoriantojd() can be used to convert such dates to their Julian Day count.
Parameters
- month
-
The month as a number from 1 (for January) to 12 (for December)
- day
-
The day as a number from 1 to 31
- year
-
The year as a number between -4713 and 9999
Return Values
The julian day for the given julian date as an integer.
See Also
- jdtojulian() - Converts a Julian Day Count to a Julian Calendar Date
- cal_to_jd() - Converts from a supported calendar to Julian Day Count
JulianToJD
16-Apr-2009 01:23
