PHP Function Reference

PHP jdtogregorian() Function



The PHP jdtogregorian() function converts a Julian Day Count to the Gregorian date. The function takes a Julian Day integer and returns the converted Gregorian date as a string in the form "month/day/year".

Syntax

jdtogregorian(julian_day)

Parameters

julian_day Required. Specify a Julian day number as integer.

Return Value

Returns the Gregorian date as a string in the form "month/day/year".

Exceptions

NA.

Example:

The example below shows the usage of jdtogregorian() function.

<?php
//converting a Gregorian date
//to Julian integer 
$jd = gregoriantojd(10, 2, 2015);
  
//displaying the Julian day integer 
echo "The Julian day integer is: $jd \n";
  
//converting the Julian day integer 
//to Gregorian date
$date = jdtogregorian($jd);
  
//displaying the Gregorian date
echo "The Gregorian date is: $date \n"; 
?>

The output of the above code will be:

The Julian day integer is: 2457298 
The Gregorian date is: 10/2/2015 

Example: Overflow behavior

Consider one more example to see the overflow behavior of this function.

<?php
//converting an invalid Gregorian 
//date to Julian integer 
$jd = gregoriantojd(15, 2, 2018);
  
//prints 0 as month is out of range 
echo "The Julian day integer is: $jd \n";
  
//converting the Julian day integer 
//to Gregorian date
$date = jdtogregorian($jd);
  
//prints 0/0/0 as Gregorian 
//month is out of range
echo "The Gregorian date is: $date \n"; 
?>

The output of the above code will be:

The Julian day integer is: 0 
The Gregorian date is: 0/0/0 

❮ PHP Calendar Reference