Skip to content
Related Articles
Open in App
Not now

Related Articles

PHP | juliantojd() Function

Improve Article
Save Article
  • Last Updated : 05 Jan, 2023
Improve Article
Save Article

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:  

PHP




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

Output

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

Program 2: 

PHP




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

Output

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

Related Articles: 

Reference: http://php.net/manual/en/function.juliantojd.php
 


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!