PHP - Calendar jdmonthname() Function
The PHP Calendar jdmonthname() function is used to return a string containing a month name. mode tells this function which calendar to convert the Julian Day Count to, and what type of month names are to be returned.
Syntax
Below is the syntax of the PHP Calendar jdmonthname() function −
string jdmonthname(int $jd, int $mode)
Parameters
Below are the parameters of the jdmonthname() function −
$jd − It is the Calendar handle returned by Calendar_init().
$mode − It defines which calendar to convert the Julian day count to, and what type of month names are to be returned.
Mode values are as follows −
- 0 − Gregorian - abbreviated (Jan, Feb, Mar, etc.)
- 1 − Gregorian (January, February, March, etc.)
- 2 − Julian - abbreviated (Jan, Feb, Mar, etc.)
- 3 − Julian (January, February, March, etc.)
- 4 − Jewish (Tishri, Heshvan, Kislev, etc.)
- 5 − French Republican (Vendemiaire, Brumaire, Frimaire, etc.)
Return Value
The jdmonthname() function returns the month name for the given Julian Day and calendar.
PHP Version
First introduced in core PHP 4, the jdmonthname() function continues to function easily in PHP 5, PHP 7, and PHP 8.
Example 1
First we will show you the basic example of the PHP Calendar jdmonthname() function to get the full name of a month with the help of Julian Day Count.
<?php // January 1, 2000 in the Julian calendar $jd = 2451545; // Get the full month name $monthName = jdmonthname($jd, 0); // Display the result echo "The full month name is: $monthName"; ?>
Output
Here is the outcome of the following code −
The full month name is: January
Example 2
This example shows how to use the Julian Day Count to find the month's shortened name with the help of jdmonthname() function.
<?php // January 1, 2000 in the Julian calendar $jd = 2451545; // Get the abbreviated month name $monthName = jdmonthname($jd, 1); // Display the result echo "The abbreviated month name is: $monthName"; ?>
Output
This will generate the below output −
The abbreviated month name is: Jan
Example 3
This example shows how to use the Julian Day Count to get a month's numerical representation using the jdmonthname() function.
<?php // December 1, 2000 in the Julian calendar $jd = 2451535; // Get the numeric month representation $monthNumber = jdmonthname($jd, 2); // Display the result echo "The numeric month is: $monthNumber"; ?>
Output
This will create the below output −
The numeric month is: 12