<?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: כ"ט אדר התשע"ב
?>
jdtojewish
(PHP 4, PHP 5)
jdtojewish — Convertit le nombre de jours du calendrier Julien en date du calendrier juif
Description
string jdtojewish
( int
$juliandaycount
[, bool $hebrew = false
[, int $fl = 0
]] )Convertit le nombre de jours du calendrier Julien en date du calendrier juif.
Les paramètres optionnels hebrew et
fl sont disponibles depuis PHP 5.0.0.
Si le paramètre hebrew vaut TRUE, le paramètre
fl sera utilisé pour générer une chaîne au
format hébreux. Les formats disponibles sont :
CAL_JEWISH_ADD_ALAFIM_GERESH,
CAL_JEWISH_ADD_ALAFIM et
CAL_JEWISH_ADD_GERESHAYIM.
Valeurs de retour
La date Juive, sous la forme d'une chaîne de caractères "mois/jour/année".
Historique
| Version | Description |
|---|---|
| 5.0.0 |
Les paramètres hebrew et fl
ont été ajoutés.
Le paramètre fl a été ajouté.
|
| 4.3.0 |
Le paramètre hebrew a été ajouté.
|
Exemples
Exemple #1 Exemple avec jdtojewish()
<?php
echo jdtojewish(gregoriantojd(10, 8, 2002), true,
CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH);
?>
Voir aussi
- jewishtojd() - Convertit une date du calendrier Juif en nombre de jours du calendrier Julien
- cal_from_jd() - Convertit le nombre de jours Julien en un calendrier spécifique
adam at tadam dot co dot il ¶
1 year ago
erelsgl at gmail dot com ¶
3 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))));
}
?>
erelsgl at gmail dot com ¶
3 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.
asphp at dsgml dot com ¶
5 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");
?>
gr8g0thamguy at yahoo dot com ¶
9 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";
?>
dave_at_mitzvahweb.com ¶
11 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";
?>
