PHP - Calendar jewishtojd () Function
The PHP Calendar jewishtojd() function is used to convert a date from the Jewish calendar to the Julian Day Count. It is a continuous count of days since the beginning of the Julian period. This function is very useful when working with dates from the Hebrew calendar and wants to perform computations or comparisons.
Syntax
Below is the syntax of the PHP Calendar jewishtojd() function −
int jewishtojd ( int $month , int $day , int $year )
Parameters
Below are the parameters of the jewishtojd() function −
$month − It is the month as a number from 1 to 13.
$day − It is the day as a number from 1 to 30.
$year − It is the year as a number between 1 and 9999.
Return Value
The jewishtojd() function returns the julian day for the given jewish date as an integer.
PHP Version
First introduced in core PHP 4, the jewishtojd() function continues to function easily in PHP 5, PHP 7, and PHP 8.
Example 1
First we will show you the basic example of the PHP Calendar jewishtojd() function to convert Jewish calendar date to Julian Day Count.
<?php // Convert jewish to Julian Day count echo "The Julian Day Count is as follows: "; echo(jewishtojd(12,10,5060)); ?>
Output
Here is the outcome of the following code −
The Julian Day Count is as follows: 2196091
Example 2
This example used the convertToJulianDay() function to convert a date from the Jewish date to the Julian Day Count.
<?php
// Create a function to convert jewish date to julian day count
function convertToJulianDay($month, $day, $year) {
return jewishtojd($month, $day, $year);
}
// Display the result
echo "The converted date is as follows: ";
echo convertToJulianDay(1, 1, 5784);
?>
Output
This will create the below output −
The converted date is as follows: 2460204
Example 3
This example shows how to develop a simple class that converts a standard Jewish date (1, 1, 5784) to Julian Day Count using the jewishtojd() function.
<?php
// Create a converter class
class Converter {
public function convertToJulianDay($month, $day, $year) {
return jewishtojd($month, $day, $year);
}
}
$converter = new Converter();
echo $converter->convertToJulianDay(1, 1, 5784);
?>
Output
This will generate the below output −
2460204