PHP jdmonthname() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Calendar

Definition

In PHP, jdmonthname() returns the name of the month for a Julian Day number, in the calendar and style that you choose with the mode.

The mode tells PHP both which calendar to use and whether you want the short or the long name. For everyday work you will use mode 0 for a short Gregorian name like Jan or mode 1 for a full name like January.

Syntax

Call jdmonthname() with the values you need. Start with this line.

PHP
$month = jdmonthname($jd, CAL_MONTH_GREGORIAN_LONG);
CallWhat it does
jdmonthname($jd, CAL_MONTH_GREGORIAN_SHORT)Returns a short name such as Jan.
jdmonthname($jd, CAL_MONTH_GREGORIAN_LONG)Returns a full name such as January.
jdmonthname($jd, CAL_MONTH_JULIAN_LONG)Returns the full month name using the Julian calendar.

The modes are CAL_MONTH_GREGORIAN_SHORT (0), CAL_MONTH_GREGORIAN_LONG (1), CAL_MONTH_JULIAN_SHORT (2), CAL_MONTH_JULIAN_LONG (3), CAL_MONTH_JEWISH (4) and CAL_MONTH_FRENCH (5). In PHP 8 the mode argument is required.

Library declarations
PHP
jdmonthname(int $julian_day, int $mode): string

Parameters

ParameterDescription
julian_dayRequired. The Julian Day number, for example from gregoriantojd().
modeRequired. A calendar mode constant: CAL_MONTH_GREGORIAN_SHORT (0), CAL_MONTH_GREGORIAN_LONG (1), CAL_MONTH_JULIAN_SHORT (2), CAL_MONTH_JULIAN_LONG (3), CAL_MONTH_JEWISH (4) or CAL_MONTH_FRENCH (5).

Return Value

Return ValueDescription
stringThe month name in English. If the Julian Day is outside the range of the chosen calendar, the result is an empty string.

PHP Examples

Example 1 — Short and Long Month Names

Get the month name for January 1, 2000 in the Gregorian and Julian calendars, in short and long form.

PHP
<?php
$jd = gregoriantojd(1, 1, 2000);

echo jdmonthname($jd, 0), PHP_EOL;
echo jdmonthname($jd, 1), PHP_EOL;
echo jdmonthname($jd, 2), PHP_EOL;
echo jdmonthname($jd, 3), PHP_EOL;

How It Works

  1. Mode 0 gives the short Gregorian name, and mode 1 gives the full Gregorian name.
  2. Modes 2 and 3 use the Julian calendar instead of the Gregorian one.
  3. January 1, 2000 is December 19, 1999 in the Julian calendar.
  4. So the Julian modes return Dec and December.

Example 2 — Other Calendars and Empty Results

The Jewish and French modes use their own month names. A Julian Day outside the French calendar range returns an empty string.

PHP
<?php
$jd = gregoriantojd(1, 5, 2024);

echo jdmonthname($jd, CAL_MONTH_GREGORIAN_LONG), PHP_EOL;
echo jdmonthname($jd, CAL_MONTH_JULIAN_LONG), PHP_EOL;
echo jdmonthname(jewishtojd(1, 1, 5784), CAL_MONTH_JEWISH), PHP_EOL;
var_dump(jdmonthname($jd, CAL_MONTH_FRENCH));

How It Works

  1. January 5, 2024 is in January in the Gregorian calendar.
  2. The same day is December 23, 2023 in the Julian calendar, so the Julian mode returns December.
  3. The first month of the Jewish year is Tishri, returned by mode 4.
  4. The year 2024 is far outside the French calendar range, so mode 5 returns an empty string.

Example 3 — List All Month Names

Loop through the months of 2024 and collect the short month names.

PHP
<?php
$names = [];

for ($month = 1; $month <= 12; $month++) {
    $jd = gregoriantojd($month, 1, 2024);
    $names[] = jdmonthname($jd, CAL_MONTH_GREGORIAN_SHORT);
}

echo implode(', ', $names), PHP_EOL;

How It Works

  1. The loop runs from month 1 to month 12.
  2. gregoriantojd() makes a Julian Day for the first day of each month.
  3. jdmonthname() with the short Gregorian mode returns the abbreviated name.
  4. implode() joins all twelve names into one line of text.

Frequently Asked Questions

It returns the name of the month that a Julian Day falls in. You choose the calendar and whether the name is short or long with the mode argument.
Use CAL_MONTH_GREGORIAN_LONG (1) for names like January, or CAL_MONTH_GREGORIAN_SHORT (0) for names like Jan. These follow the calendar used in daily life.
Yes, in PHP 8 you must pass a mode. Use the constants like CAL_MONTH_GREGORIAN_LONG to keep your code easy to read.
No. It only returns English names. For other languages, use the month number with your own array, or use the intl extension.
Yes. If PHP says that jdmonthname() is undefined, enable extension=calendar in php.ini or install the php-calendar package.

Next: jdtofrench()

jdtofrench() converts a Julian Day number into a French Republican date string.

jdtofrench() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful