PHP | cal_to_jd() Function

The cal_to_jd() function is an inbuilt function in PHP which is used to converts a specified date into Julian Day Count. The cal_to_jd() function calculates the Julian day count for a date in the specified calendar. This function supports CAL_GREGORIAN, CAL_JULIAN, CAL_JEWISH and CAL_FRENCH calandars.

Syntax:

int cal_to_jd( $calendar, $month, $day, $year )

Parameters: This function accepts four parameters as mentioned above and described below:

  • $calendar: It is used to specify the calendar for calculation. The calendar values are Gregorian calendar, French calendar, Jewish calendar and Julian calendar.
  • $month: It is used to specify the Month in the selected calendar.
  • $day: It is used to specify the Day in the selected calendar.
  • $year : It is used to specify the year in the selected calendar.

Return Value: This function returns a Julian Day number.

Below programs illustrate the cal_to_jd() function in PHP.



Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
      
// Converts a Gregorian calender Date 
// into Julian Day number.
$date = cal_to_jd(CAL_GREGORIAN, 11, 03, 2007);
  
// Prints the conversion of date to 
// Julain Day number.
echo $date;
?> 

chevron_right


Output:

2454408

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Converts Julian calender Date into 
// Julian Day count.
$date = cal_to_jd(CAL_JULIAN, 7, 20, 20017);
  
// Prints the above conversion.
echo $date;
?>

chevron_right


Output:

9032468

Related Articles:

Reference: http://php.net/manual/en/function.cal-to-jd.php

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.