PHP cal_to_jd() Function
The PHP cal_to_jd() function calculates the Julian day count for a date in the specified calendar. Supported calendars by this function are CAL_GREGORIAN, CAL_JULIAN, CAL_JEWISH and CAL_FRENCH.
Syntax
cal_to_jd(calendar, month, day, year)
Parameters
calendar |
Required. Specify the Calendar to convert from. Must be one of the following values:
|
month |
Required. Specify the month as a number, the valid range depends on the calendar. |
day |
Required. Specify the day as a number, the valid range depends on the calendar. |
year |
Required. Specify the year as a number, the valid range depends on the calendar. |
Return Value
Returns the Julian day count for a date in the specified calendar.
Exceptions
NA.
Example:
The example below shows the usage of cal_to_jd() function.
<?php //converting a Gregorian calendar Date //into Julian Day count $date = cal_to_jd(CAL_GREGORIAN, 10, 23, 2015); //displaying the result echo "The Julian day count is: $date"; ?>
The output of the above code will be:
The Julian day count is: 2457319
Example:
Consider one more example where a date in other calendar types are converted into Julian Day count.
<?php //converting a Jewish calendar Date //into Julian Day count $date = cal_to_jd(CAL_JEWISH, 10, 23, 2015); //displaying the result echo "The Julian day count is: $date \n"; //converting a French Republican calendar //Date into Julian Day count $date = cal_to_jd(CAL_FRENCH, 10, 23, 12); //displaying the result echo "The Julian day count is: $date \n"; ?>
The output of the above code will be:
The Julian day count is: 1083864 The Julian day count is: 2380150
❮ PHP Calendar Reference