PHP | juliantojd() Function

The juliantojd() function is an inbuilt function in PHP which is used to convert Julian calendar Date to Julian Day count. The range of date for Julian Calendar is valid from Julian Calendar 4713 B.C.(Before Christ) to 9999 A.D.(anno domini).

Syntax:

int juliantojd( $month, $day, $year )

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



  • $month: It is a mandatory parameter which is used to specify the month number in Julian Calendar. The month number is in range 1 (i.e January) to 12 (i.e December).
  • $day: It is a mandatory parameter which is used to specify the day in Julian calendar. The day number is in range 1 to 31.
  • $year: It is a mandatory parameter which is used to specify the year in Julian calendar. The year number is from -4713 to 9999.

Return Value: This function returns a Julian Day for the given Julian date.

Exceptions: The Valid range of the Julian calendar is 4713 B.C. to 9999 A.D.

Below programs illustrate the juliantojd() function in PHP.

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// converts Julian calender Date to 
// Julian Day number. 
$jdate = juliantojd(8, 30, 2018);
  
// printd the Julian Day Count
echo "Julian Day count: " . $jdate . "\n";
      
// converts Julian Day number to 
// Julian calender Date.
$julian = jdtojulian($jdate);
  
// prints the Julian calender Date.
echo "Julian calender: " . $julian;
  
?> 

chevron_right


Output:

Julian Day count: 2458374
Julian calender: 8/30/2018

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// convert Julian Calender Date to Julian Day number.
$jdate = juliantojd(12, 3, 2001);
  
// prints the Julian calender.
echo "Julian calender " . $jdate . "\n";
      
// convert Julian calender Date into julian Day number.
$julian = jdtojulian($jdate);
  
// print the Julian date number.
echo "Julian Date Count : " . $julian;
?> 

chevron_right


Output:

Julian calender 2452260
Julian Date Count : 12/3/2001

Related Articles:

Reference: http://php.net/manual/en/function.juliantojd.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.