文字

jdtojewish

(PHP 4, PHP 5, PHP 7)

jdtojewish转换一个julian天数为Jewish历法的日期

说明

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

转换一个julian天数为Jewish历法的日期。

参数

julianday

一个julian天数

hebrew

如果参数 hebrew设置为 TRUE ,参数fl可用于希伯莱语的格式。

fl

可用的格式有: CAL_JEWISH_ADD_ALAFIM_GERESH , CAL_JEWISH_ADD_ALAFIM , CAL_JEWISH_ADD_GERESHAYIM .

返回值

以“月/日/年”的格式显示jewish日期。

更新日志

版本 说明
5.0.0 增加了参数 fl
4.3.0 增加了参数 hebrew

范例

Example #1 jdtojewish() Example

<?php
echo  jdtojewish ( gregoriantojd ( 10 8 2002 ),  true ,
       
CAL_JEWISH_ADD_GERESHAYIM  CAL_JEWISH_ADD_ALAFIM  CAL_JEWISH_ADD_ALAFIM_GERESH ); 
?>

参见

  • jewishtojd() - 转变一个Jewish历法的日期为一个Julian Day计数
  • cal_from_jd() - 转换Julian Day计数到一个支持的历法。

用户评论:

[#1] eclipsechasers2 at yahoo dot com [2015-01-06 00:34:11]

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".

[#2] adam at tadam dot co dot il [2012-03-23 09:57:39]

<?php
// Hebrew date in hebrew
$str jdtojewish(gregoriantojddate('m'), date('d'), date('Y')), trueCAL_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(gregoriantojddate('m'), date('d'), date('Y')), trueCAL_JEWISH_ADD_GERESHAYIM); // for today
$str1 iconv ('WINDOWS-1255''UTF-8'$str); // convert to utf-8

echo $str1// for 23/03/2012 will print: ?"? ??? ????"?
?>

[#3] erelsgl at gmail dot com [2009-08-29 15:28:55]

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))));
}
?>

[#4] erelsgl at gmail dot com [2009-08-29 14:01:06]

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.

[#5] asphp at dsgml dot com [2007-05-28 14:10:10]

This function outputs in ISO-8859-8-l.

To convert to unicode UTF-8 do this:

<?php

echo mb_convert_encodingjdtojewishunixtojd(), true ), "UTF-8""ISO-8859-8");

?>

[#6] gr8g0thamguy at yahoo dot com [2003-09-01 11:39:24]

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";
?>

[#7] dave_at_mitzvahweb.com [2002-03-04 16:04:03]

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);

$hebrewDate jdtojewish ($jdDate);

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

$hebrewMonthName jdmonthname $jdDate4);  

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

?>

上一篇: 下一篇: