PHP juliantojd() Function
The PHP juliantojd() function converts a Julian Calendar date to Julian Day Count. The valid range for Julian Calendar for this function is 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., and it did not stabilize until at least 8 A.D. Also, the beginning of a year varied from one culture to another - not all accepted January as the first month.
Syntax
juliantojd(month, day, year)
Parameters
month |
Required. Specify the month as a number from 1 (for January) to 12 (for December). |
day |
Required. Specify the day as a number from 1 to 31. |
year |
Required. Specify the year as a number between -4713 and 9999. |
Return Value
Returns the Julian Day count for the given Julian Calendar date. Dates outside the valid range return 0.
Exceptions
NA.
Example:
The example below shows the usage of juliantojd() function.
<?php //converting a Julian Calendar Date //to Julian integer $jd = juliantojd(10, 2, 2015); //displaying the Julian day integer echo "The Julian day integer is: $jd \n"; //converting the Julian day integer //to Julian Calendar Date $date = jdtojulian($jd); //displaying the Julian Calendar Date echo "The Julian Calendar Date is: $date \n"; ?>
The output of the above code will be:
The Julian day integer is: 2457311 The Julian Calendar Date is: 10/2/2015
Example: Overflow behavior
Consider one more example to see the overflow behavior of this function.
<?php //converting an invalid Julian Calendar //date to Julian integer $jd = juliantojd(15, 2, 2018); //prints 0 as month is out of range echo "The Julian day integer is: $jd \n"; //converting the Julian day integer //to Julian Calendar Date $date = jdtojulian($jd); //prints 0/0/0 as Julian Calendar //month is out of range echo "The Julian Calendar Date is: $date \n"; ?>
The output of the above code will be:
The Julian day integer is: 0 The Julian Calendar Date is: 0/0/0
❮ PHP Calendar Reference