PHP 8.4.2 Released!

jdtojewish

(PHP 4, PHP 5, PHP 7, PHP 8)

jdtojewishConverte uma contagem de dias Julianos para uma data do calendário Judeu

Descrição

jdtojewish(int $julian_day, bool $hebrew = false, int $flags = 0): string

Converte uma contagem de dias Julianos para o calendário Judeu.

Parâmetros

julian_day

O número do dia Juliano como um inteiro

hebrew

Se o parâmetro hebrew for definido para true, o parâmetro flags é usado para o formato de saída hebraico, baseado em string codificado em ISO-8859-8.

flags

Uma máscara de bits que pode consistir em CAL_JEWISH_ADD_ALAFIM_GERESH, CAL_JEWISH_ADD_ALAFIM e CAL_JEWISH_ADD_GERESHAYIM.

Valor Retornado

A data Judia como uma string no formato "mês/dia/ano", ou uma data string codificada em em ISO-8859-8, hebraico, de acordo com o parâmetro hebrew.

Exemplos

Exemplo #1 Exemplo de jdtojewish()

<?php
$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;
?>

O exemplo acima produzirá:

ב חשון התשסג
ב' חשון התשס"ג
ב חשון ה אלפים תשסג
ב חשון ה'תשסג

Veja Também

  • jewishtojd() - Converte uma data do calendário Judaico para o calendário "Julian Day Count"
  • cal_from_jd() - Converte de uma Contagem de Dias Julianos para um calendário suportado

adicione uma nota

Notas Enviadas por Usuários (em inglês) 10 notes

up
12
adam at tadam dot co dot il
12 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
9
eclipsechasers2 at yahoo dot com
9 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
asphp at dsgml dot com
17 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
3
Berel
4 years ago
If you wish to format the hebrew date as this (ignore the brackets): [כ"ז סיון ה'תשע"ה], since none of the 3 bitmasks include this format, you can use the CAL_JEWISH_ADD_GERESHAYIM mask, and then insert the ' into the year with the second line, as shown:

$hebdate = jdtojewish(gregoriantojd(6,14,2015),1,CAL_JEWISH_ADD_GERESHAYIM);
$hebdate = substr_replace($hebdate,"'",strrpos($hebdate," ")+2,0);
up
3
gr8g0thamguy at yahoo dot com
21 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
5
erelsgl at gmail dot com
15 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
dave_at_mitzvahweb.com
22 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";

?>
up
1
WWW dot netfree at gmail dot com
5 years ago
Check whether the year is leap year, in order to determine whether the value 7 = Adar or Adar 2

<?php

$hebrewDate
= jdtojewish(gregoriantojd(date('m', $DateStamp), date('d', $DateStamp), date('Y', $DateStamp)));
list(
$hebrewMonth, $hebrewDay, $hebrewYear) = explode('/',$hebrewDate);

$m = array(3, 6, 8, 11, 14, 17, 19);
$meuberet = in_array(($hebrewYear % 19), $m);
if(
$meuberet) if($hebrewMonth == 7) $hebrewMonth = '7b'; //This is Adar 2
up
1
Sergio Z
2 years ago
To check if a Jewish year is leap use this function:

function isJewishLeapYear($year) {
return 0 != cal_days_in_month(CAL_JEWISH, 6, $year);
}

In non-leap years there is only one Adar, and its number is 7. There is no 6.
up
1
erelsgl at gmail dot com
15 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))));
}
?>
To Top