Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

PHP - Calendar jdtojewish() Function



The PHP Calendar jdtojewish() function is used to convert a Julian day count to a Jewish calendar date. If the hebrew parameter is set to TRUE, the fl parameter is used for Hebrew, string based, output format.

Syntax

Below is the syntax of the PHP Calendar jdtojewish() function −

string jdtojewish ( int $jdc, bool $hebrew = false, int $fl = 0 )

Parameters

Below are the parameters of the jdtojewish() function −

  • $jdc − It is a julian day number as integer.

  • $hebrew − True indicates Hebrew output format.

  • $fl − It is the optional parameter and it defines the Hebrew output format. The available formats are − CAL_JEWISH_ADD_ALAFIM_GERESH, CAL_JEWISH_ADD_ALAFIM and CAL_JEWISH_ADD_GERESHAYIM.

Return Value

The jdtojewish() function returns the jewish date as a string in the form "month/day/year".

PHP Version

First introduced in core PHP 4, the jdtojewish() function continues to function easily in PHP 5, PHP 7, and PHP 8.

Example 1

Here is the basic example of the PHP Calendar jdtojewish() function to get converted a simple Julian Day Count to a Jewish date.

<?php
   // Julian Day Count
   $jdc = 2451545;

   // Date Conversion
   $jewish_date = jdtojewish($jdc);

   //Display the result
   echo "The Jewish Date is as follows: ".$jewish_date;
?>

Output

Here is the outcome of the following code −

The Jewish Date is as follows: 4/23/5760

Example 2

This example explains how to use a formatting option to get the Jewish date in a different format using the jdtojewish() function and its parameters.

<?php
   // Julian Day Count
   $jdc = 2451545;

   // Conversion
   $jewish_date_formatted = jdtojewish($jdc, false, 1);

   // Display the result
   echo "Formatted Jewish Date is as follows: ".$jewish_date_formatted;
?> 

Output

This will generate the below output −

Formatted Jewish Date is as follows: 4/23/5760

Example 3

Now the below code will first change the given gregorian date to julian date and then convert it in the jewish date using the jdtojewish() method.

<?php
   // Julian Date
   $jd = gregoriantojd(10, 8, 2002);
   echo jdtojewish($jd, true), PHP_EOL,
      jdtojewish($jd, true, CAL_JEWISH_ADD_GERESHAYIM), PHP_EOL,
      jdtojewish($jd, true, CAL_JEWISH_ADD_ALAFIM), PHP_EOL,
      jdtojewish($jd, true,CAL_JEWISH_ADD_ALAFIM_GERESH), PHP_EOL;
?> 

Output

This will create the below output −

  
'  "
    
  '
php_function_reference.htm
Advertisements