Tutorialspoint.dev

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:

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

Output:

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

Program 2:

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

Output:

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

Related Articles:

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



This article is attributed to GeeksforGeeks.org

You Might Also Like

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter