Home Menu

gregoriantojd

Converts a Gregorian date to Julian Day Count

Syntax

gregoriantojd ( int $month , int $day , int $year ) : int

Parameters

month

The month as a number from 1 (January) to 12 (December)

day

The day as a number from 1 to 31. If the month has less days then given, overflow occurs.

year

The year as a number between -4714 and 9999. Negative numbers mean years B.C., positive numbers mean years A.D. Note that there is no year 0; December 31, 1 B.C. is immediately followed by January 1, 1 A.D.

Return

The julian day for the given gregorian date as an integer. Dates outside the valid range return 0.

Examples

month day year

<?

$month = 1;
$day = 1;
$year = 1;

$return = gregoriantojd($month, $day, $year);

echo $return;

?>
1721426

Overflow

<?

$month1 = 2;
$month2 = 3;
$day1 = 31;
$day2 = 3;
$year = 1;

$return1 = gregoriantojd($month1, $day1, $year);
$return2 = gregoriantojd($month2, $day2, $year);

echo $return1 . PHP_EOL;
echo $return2;

?>
1721487
1721487

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms