Use this function if you prefer to use the standard calendar constants:
<?php
function jdmonthname2($julianday, $calendar, $abbrev = false) {
if($calendar == CAL_GREGORIAN && $abbrev) $mode = 0;
elseif($calendar == CAL_GREGORIAN && !$abbrev) $mode = 1;
elseif($calendar == CAL_JULIAN && $abbrev) $mode = 2;
elseif($calendar == CAL_JULIAN && !$abbrev) $mode = 3;
elseif($calendar == CAL_JEWISH) $mode = 4;
elseif($calendar == CAL_FRENCH) $mode = 5;
else $mode = 10; //use an invalid mode and let the underlying function handle it
return jdmonthname($julianday, $mode);
}
?>
JDMonthName
(PHP 4, PHP 5)
JDMonthName — Retorna o nome de um mês
Descrição
string jdmonthname
( int
$julianday
, int $mode
)
Retorna uma "string" contendo o nome do mês.
O parâmetro mode diz à função
qual calendário será convertido para o formato "Julian Day Count",
e o tipo do nome do mês.
| Modo | Significado | Valores |
|---|---|---|
| 0 | Gregoriano - abreviado | Jan, Fev, Mar, Abr, Mai, Jun, Jul, Ago, Set, Out, Nov, Dez |
| 1 | Gregoriano | Janeiro, Fevereiro, Março, Abril, Maio, Junho, Julho, Agosto, Setembro, Outubro, Novembro, Dezembro |
| 2 | "Julian" - abreviado | Jan, Fev, Mar, Abr, Mai, Jun, Jul, Ago, Set, Out, Nov, Dez |
| 3 | "Julian" | Janeiro, Fevereiro, Março, Abril, Maio, Junho, Julho, Agosto, Setembro, Outubro, Novembro, Dezembro |
| 4 | Judeu | Tishri, Heshvan, Kislev, Tevet, Shevat, AdarI, AdarII, Nisan, Iyyar, Sivan, Tammuz, Av, Elul |
| 5 | Republicano Francês | Vendemiaire, Brumaire, Frimaire, Nivose, Pluviose, Ventose, Germinal, Floreal, Prairial, Messidor, Thermidor, Fructidor, Extra |
Parâmetros
-
jday -
A data juliana
-
calendar -
O calendário para obter o nome do mês
Valor Retornado
O nome do mês para a dada data juliana e calendar.
asphp at dsgml dot com ¶
2 years ago
doug at exploittheweb dot com ¶
10 months ago
<?php
/* Simplest way to get current abbreviated month name */
echo date('M');
?>
viju dot kantah at gmail dot com ¶
1 year ago
<?php
/* Simple way to get current month name */
$mons = array(1 => "Jan", 2 => "Feb", 3 => "Mar", 4 => "Apr", 5 => "May", 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10 => "Oct", 11 => "Nov", 12 => "Dec");
$date = getdate();
$month = $date['mon'];
$month_name = $mons[$month];
echo $month_name; // Displays the current month
?>
ukarmakar at gmail dot com ¶
3 years ago
You can get the month name by passing the month integer value to a simple function....
<?php
function getMonthName($Month){
$strTime=mktime(1,1,1,$Month,1,date("Y"));
return date("F",$strTime);
}
echo getMonthName(10);
?>
Output:
October
Shai ¶
7 years ago
YIQV, this should correct your issue with Adar being displayed as AdarI:
<?php
// assuming that $jewish_month is the Jewish month,
// and $jewish_year is the Jewish year,
// you can use this script to replace 'Adar I' with 'Adar' when it is not a leap year.
// this is because a Jewish leap year occurs every 3rd, 6th, 8th, 11th, 14th, 17th, and 19th year.
if( $jewish_month == "AdarI" &&
$jewish_year%19 != 0 &&
$jewish_year%19 != 3 &&
$jewish_year%19 != 6 &&
$jewish_year%19 != 8 &&
$jewish_year%19 != 11 &&
$jewish_year%19 != 14 &&
$jewish_year%19 != 17
) {
$jewish_month = "Adar";
}
?>
YIQV ¶
8 years ago
I am finding an inconsistency in the Jewish month Adar. The function always returns AdarI regardless of whether the year is a jewish leapyear. The month is known as Adar (not AdarI) in non-leap years. Also when using function jdtojewish with bool hebrew set to true it always returns (ADR) and not (ADR A) when it's a leap year. AdarII in Hebrew and English seems to work properly.
