Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<cal_infoeaster_date>
^Calendar FunctionsLast updated: Mon, 26 Oct 2026

cal_to_jd

(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)

cal_to_jd — Converts from a supported calendar to Julian Day Count

Description

function cal_to_jd(
    int $calendar,
    int $month,
    int $day,
    int $year
): int

cal_to_jd() calculates the Julian day count for a date in the specified calendar. Supported calendars are CAL_GREGORIAN, CAL_JULIAN, CAL_JEWISH and CAL_FRENCH.

Parameters

calendar

Calendar to convert from, one of CAL_GREGORIAN, CAL_JULIAN, CAL_JEWISH or CAL_FRENCH.

month

The month as a number, the valid range depends on the calendar

day

The day as a number, the valid range depends on the calendar

year

The year as a number, the valid range depends on the calendar

Return Values

A Julian Day number.

Errors/Exceptions

Throws a ValueError if calendar is not a valid calendar ID, if month is less than 1, or if month, day or year exceeds the supported 32-bit range. Other invalid dates return 0.

Changelog

Version Description
8.0.0 Now throws a ValueError if calendar is not a valid calendar ID. Previously, an E_WARNING was raised and false was returned.

See Also

  • cal_from_jd() - Converts from Julian Day Count to a supported calendar
  • frenchtojd() - Converts a date from the French Republican Calendar to a Julian Day Count
  • gregoriantojd() - Converts a Gregorian date to Julian Day Count
  • jewishtojd() - Converts a date in the Jewish Calendar to Julian Day Count
  • juliantojd() - Converts a Julian Calendar date to Julian Day Count
  • unixtojd() - Convert Unix timestamp to Julian Day


<cal_infoeaster_date>
^Calendar FunctionsLast updated: Mon, 26 Oct 2026