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))));
}
?>
jdtojewish
(PHP 4, PHP 5)
jdtojewish — ユリウス積算日をユダヤ暦に変換する
説明
string jdtojewish
( int $juliandaycount
[, bool $hebrew = false
[, int $fl = 0
]] )
ユリウス積算日をユダヤ暦に変換します。
パラメータ
- julianday
-
ユリウス積算日を表す整数値。
- hebrew
-
パラメータ hebrew が TRUE に設定されている場合、 ヘブライ語の文字列形式での出力のために fl が使用されます。
- fl
-
使用可能なフォーマットは CAL_JEWISH_ADD_ALAFIM_GERESH、 CAL_JEWISH_ADD_ALAFIM および CAL_JEWISH_ADD_GERESHAYIM です。
返り値
ユダヤ暦の日付を "月/日/年" 形式の文字列で返します。
変更履歴
| バージョン | 説明 |
|---|---|
| 5.0.0 | fl パラメータが追加されました。 |
| 4.3.0 | hebrew パラメータが追加されました。 |
例
例1 jdtojewish() の例
<?php
echo jdtojewish(gregoriantojd(10, 8, 2002), true,
CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH);
?>
jdtojewish
erelsgl at gmail dot com
29-Aug-2009 10:28
29-Aug-2009 10:28
erelsgl at gmail dot com
29-Aug-2009 09:01
29-Aug-2009 09:01
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.
asphp at dsgml dot com
28-May-2007 09:10
28-May-2007 09:10
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");
?>
gr8g0thamguy at yahoo dot com
01-Sep-2003 06:39
01-Sep-2003 06:39
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";
?>
dave_at_mitzvahweb.com
05-Mar-2002 12:04
05-Mar-2002 12:04
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";
?>
