PHP Tutorial - PHP gregoriantojd() Function






Definition

The gregoriantojd() function converts a date from the Gregorian Calendar to a Julian Day Count.

Syntax

PHP gregoriantojd() Function has the following syntax.

gregoriantojd(month,day,year);

Parameter

ParameterIs RequiredDescription
monthRequired.Month as a number from 1 to 12
dayRequired.Day as a number from 1 to 31
yearRequired.Year as a number between -4714 and 9999

Return

PHP gregoriantojd() Function returns a Julian Day number.





Example

Convert a Gregorian date to a Julian Day Count and back to a Gregorian date:


<?php
$jd=gregoriantojd(6,20,2013);
echo $jd . "\n";
echo jdtogregorian($jd);
?>

The code above generates the following result.

Example 2

The following code shows how to return the abbreviated Gregorian monthname of 13th January, 2014.


  
<?php
    $jd=gregoriantojd(1,13,2014);
    echo jdmonthname($jd,0);
?>

The code above generates the following result.