HomeLinuxHow one can Use cal_to_jd() Operate in PHP?

How one can Use cal_to_jd() Operate in PHP?


The cal_to_jd() is a PHP operate used to transform a given date right into a Julian Day Depend. With the assistance of the cal_to_jd() operate, we will decide what number of Julian days are on a given date within the chosen calendar. This operate is supported by PHP model 4.1 and later. The operate accepts 4 obligatory parameters and returns the Julian day quantity.

Syntax for cal_to_jd() Operate

The cal_to_jd() operate in PHP follows the straightforward syntax given under:

cal_to_jd(calendar, month, day, 12 months)

 
This syntax exhibits that the operate takes 4 inputs, that are:

    • calendar: A compulsory argument that specifies a calendar worth resembling CAL_GREGORIAN, CAL_JEWISH, CAL_JULIAN, and CAL_FRENCH.
    • month: A compulsory argument that specifies an integer worth for the month. Its vary is dependent upon the required calendar.
    • day: A compulsory argument that specifies an integer worth for the day. Its vary is dependent upon the required calendar.
    • 12 months: A compulsory argument that specifies an integer worth for the 12 months. Its vary is dependent upon the required calendar.

Return Worth: This operate supplies a Julian day quantity as an output.

Instance 1

This can be a easy PHP code that calls the GREGORIAN calendar to calculate a Julian quantity from its specified date utilizing the PHP cal_to_jd() operate.

< ?php
$date = cal_to_jd(CAL_GREGORIAN, 10, 03, 2010);
echo “The Julian day depend is: “, $date;
?>

 

Instance 2

This can be a easy PHP code that calls the JEWISH calendar to calculate a Julian quantity from its specified date utilizing PHP cal_to_jd() operate.

< ?php
$date = cal_to_jd(CAL_JEWISH, 10, 03, 2010);
echo “The Julian day depend is: “, $date;
?>

 

Instance 3

The next code calls the FRENCH calendar to calculate a Julian quantity from its specified date utilizing PHP cal_to_jd() operate.

< ?php
$date = cal_to_jd(CAL_FRENCH, 10, 03, 12);
echo “The Julian day depend is: “, $date;
?>

 

Conclusion

The built-in cal_to_jd() operate in PHP determines the Julian day depend utilizing the date from the required calendar. This operate helps 4 calendars which can be CAL_GREGORIAN, CAL_JEWISH, CAL_JULIAN, and CAL_FRENCH. The operate accepts 4 parameters and returns a calculated Julian day depend as an integer worth. This tutorial elaborated on the performance of the PHP cal_to_jd() operate with examples.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments