SunshinePHP 2019 CFP Started

jdtojewish

(PHP 4, PHP 5, PHP 7)

jdtojewishユリウス積算日をユダヤ暦に変換する

説明

string jdtojewish ( int $juliandaycount [, bool $hebrew = false [, int $fl = 0 ]] )

ユリウス積算日をユダヤ暦に変換します。

パラメータ

julianday

ユリウス積算日を表す整数値。

hebrew

パラメータ hebrewTRUE に設定されている場合、 ヘブライ語の文字列形式での出力のために fl が使用されます。

fl

使用可能なフォーマットは CAL_JEWISH_ADD_ALAFIM_GERESHCAL_JEWISH_ADD_ALAFIM および CAL_JEWISH_ADD_GERESHAYIM です。

返り値

ユダヤ暦の日付を "月/日/年" 形式の文字列で返します。

例1 jdtojewish() の例

<?php
echo jdtojewish(gregoriantojd(1082002), true,
       
CAL_JEWISH_ADD_GERESHAYIM CAL_JEWISH_ADD_ALAFIM CAL_JEWISH_ADD_ALAFIM_GERESH); 
?>

参考

  • jewishtojd() - ユダヤ暦の日付けをユリウス積算日に変換する
  • cal_from_jd() - ユリウス積算日からサポートされるカレンダーに変換する

add a note add a note

User Contributed Notes 7 notes

up
9
adam at tadam dot co dot il
6 years ago
<?php
// Hebrew date in hebrew
$str = jdtojewish(gregoriantojd( date('m'), date('d'), date('Y')), true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH); // for today
$str1 = iconv ('WINDOWS-1255', 'UTF-8', $str); // convert to utf-8

echo $str1; // for 23/03/2012 will print: כ"ט אדר ה' אלפים תשע"ב

// or
$str = jdtojewish(gregoriantojd( date('m'), date('d'), date('Y')), true, CAL_JEWISH_ADD_GERESHAYIM); // for today
$str1 = iconv ('WINDOWS-1255', 'UTF-8', $str); // convert to utf-8

echo $str1; // for 23/03/2012 will print: כ"ט אדר התשע"ב
?>
up
3
asphp at dsgml dot com
11 years ago
This function outputs in ISO-8859-8-l.

To convert to unicode UTF-8 do this:

<?php

echo mb_convert_encoding( jdtojewish( unixtojd(), true ), "UTF-8", "ISO-8859-8");

?>
up
5
eclipsechasers2 at yahoo dot com
3 years ago
With PHP 5.5, the functionality changed regarding Adar in a non-leap year. Prior to 5.5, the month was returned as 6. In 5.5 and 5.6, the month is returned as 7. This difference is not listed under "What has changed in PHP 5.5.x".
up
4
erelsgl at gmail dot com
8 years ago
In Hebrew leap years, the function will return 6 for Adar A, 7 for Adar B, 8 for Nisan, etc.

In Hebrew non-leap years, the function will return 6 for Adar, 8 for Nisan, etc.

i.e., the "real" Adar is Adar A.
up
2
gr8g0thamguy at yahoo dot com
14 years ago
Based on the code already posted by Dave, I've modified it to display the *current* date on a page:

<?php

$gregorianMonth
= date(n);
$gregorianDay = date(j);
$gregorianYear = date(Y);

$jdDate = gregoriantojd($gregorianMonth,$gregorianDay,$gregorianYear);

$hebrewMonthName = jdmonthname($jdDate,4);

$hebrewDate = jdtojewish($jdDate);

list(
$hebrewMonth, $hebrewDay, $hebrewYear) = split('/',$hebrewDate);

echo
"$hebrewDay $hebrewMonthName $hebrewYear";
?>
up
1
erelsgl at gmail dot com
8 years ago
Sometimes it is useful to have the date in the format YYYY-MM-DD, which is sortable (e.g. you can sort dates by sorting the strings):

<?php
function JDToSortableJewish($jd) {
    return
       
preg_replace("|(\d+)/(\d+)/(\d+)|","$3-$1-$2"// year-month-day
       
preg_replace("|/(\d)/|","/0$1/", // add zeros to the day
       
preg_replace("|^(\d)/|","0$1/"// add zeros to the month
       
JDToJewish($jd))));
}
?>
up
-1
dave_at_mitzvahweb.com
16 years ago
There's probably a simpler way to do this, but I needed to convert a Gregorian date to a Hebrew one and display it with the Hebrew month name (not the number).

Perhaps it can help somebody...

<?php

//enter your Gregorian date with the variables $gregorianMonth, $gregorianDay, and $gregorianYear using the numerical representation of the month

$jdDate = gregoriantojd ( $gregorianMonth, $gregorianDay, $gregorianYear);

$gregorianMonthName = jdmonthname ( $jdDate, 1 );

$hebrewDate = jdtojewish ($jdDate);

list (
$hebrewMonth, $hebrewDay, $hebrewYear) = split ('/', $hebrewDate);

$hebrewMonthName = jdmonthname ( $jdDate, 4); 

echo
"Your date in Hebrew would read: $hebrewDay $hebrewMonthName $hebrewYear";

?>
To Top