PHP | jdmonthname() Function

The jdmonthname() function is a built-in function in PHP which returns the month name of a Julian day number passed as the argument. The return value is of six types depending on the mode passed in the function which is explained briefly below in the parameter part.

Syntax:

 jdmonthname($jd, $mode) 

Parameters: The function accepts two parameters as shown above and described below:



  1. $jd – This parameter specifies the Julian Day as an integer. It is a mandatory parameter.
  2. $mode – This is a mandatory parameter which specifies the type of return value. The mode can be in range 0-5 inclusive.
    • 0 – It returns the abbreviated form (Jan, Feb, Mar, etc.) of month name in Gregorian calendar when mode is passed as 0.
    • 1 – It returns the month name (January, February, March, etc.) in Gregorian calendar when mode is passed as 1.
    • 2 – It returns the abbreviated form (Jan, Feb, Mar, etc.) of month name in Julian calendar when mode is passed as 2.
    • 3 – It returns the month name (January, February, March, etc.) in Julian calendar when mode is passed as 3.
    • 4 – It returns the month name(Tishri, Heshvan, Kislev, etc.) in Jewish calendar when mode is passed as 4.
    • 5 – In returns the month name(Vendemiaire, Brumaire, Frimaire, etc.) in French Republican when mode is passed as 5.

Return Value: The function returns the month name depending on the mode passed. If any value other then 0-5 is passed as mode, then the mode is taken as 0.

Examples:

Input : $jd = 2458236, $mode = 0 
Output : Apr
Explanation: In program below we have converted the 
date(4/27/2018) to the Julian Day integer which is 
2458236

Input : $jd = 2457031, $mode = 4 
Output : Tevet
Explanation: date(1/8/2015) in Julian Day integer is 2457031. 
Tevet is the month on this Julian Day integer. 

Below programs illustrate the jdmonthname() function:

Program 1: The program below demonstrates the jdmonthname() function when mode is passed as 0.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to demonstrate the use
// of jdmonthname() function 
// when mode is passed as 0
  
// converts the gregorian date to julian day integer 
$jd = gregoriantojd(4, 27, 2018); 
  
  
// prints the month name when mode is passed as 0
echo (jdmonthname($jd, 0)), "\n"
  
?>

chevron_right


Output:

Apr

Program 2: The program below demonstrates the jdmonthname() function when mode is passed as 1.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to demonstrate the use
// of jdmonthname() function 
// when mode is passed as 1
  
// converts the gregorian date to julian day integer 
$jd = gregoriantojd(4, 27, 2018); 
  
  
// prints the month name when mode is passed as 1
echo (jdmonthname($jd, 1)), "\n"
  
?>

chevron_right


Output:

April 

Program 3: The program below demonstrates the jdmonthname() function when mode is passed as 2.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to demonstrate the
// use of jdmonthname() function 
// when mode is passed as 2
  
// converts the gregorian date to julian day integer 
$jd = gregoriantojd(4, 27, 2018); 
  
  
// prints the month name when mode is passed as 2
echo (jdmonthname($jd, 2)), "\n"
  
?>

chevron_right


Output:

Apr

Program 4: The program below demonstrates the jdmonthname() function when mode is passed as 3.


filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to demonstrate the
// use of jdmonthname() function 
// when mode is passed as 3
  
// converts the gregorian date to julian day integer 
$jd = gregoriantojd(4, 27, 2018); 
  
  
// prints the month name when mode is passed as 3
echo (jdmonthname($jd, 3)), "\n"
  
?>

chevron_right


Output:

April

Program 5: The program below demonstrates the jdmonthname() function when mode is passed as 4.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to demonstrate the
// use of jdmonthname() function 
// when mode is passed as 4
  
// converts the gregorian date to julian day integer 
$jd = gregoriantojd(4, 27, 2018); 
  
  
// prints the month name when mode is passed as 3
echo (jdmonthname($jd, 4)), "\n"
  
?>

chevron_right


Output:

Iyyar

Program 6: The program below demonstrates the jdmonthname() function when mode is passed out of range.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to demonstrate the
// use of jdmonthname() function 
// when mode is passed out of range
  
// converts the gregorian date to julian day integer 
$jd = gregoriantojd(4, 27, 2018); 
  
  
// prints the month name when mode is passed out of range
echo (jdmonthname($jd, 8)), "\n"
  
?>

chevron_right


Output:

Apr

Reference:
http://php.net/manual/en/function.jdmonthname.php



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : shubham_singh

Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.