Thursday, October 23, 2025
HomeLanguagesPHP | cal_from_jd() Function

PHP | cal_from_jd() Function

The cal_from_jd() function is an inbuilt function in PHP that is used to convert a Julian Day Count into a supported calendar such as the Gregorian calendar, French Calendar, Jewish calendar, etc. This function accepts two parameters $jd and $calendar and returns the array containing calendar information of the specified calendar. 

Syntax:

array cal_from_jd( $jd, $calendar )

Parameters: This function accepts two parameters as mentioned above and described below:

  • $jd: It is used to specify the Julian day as an integer.
  • $calendar: It is used to specify the calendar in which the date is converted. The supported calendars are the Gregorian calendar, Julian calendar, French calendar, and Jewish calendar.

Return Value: This function returns an array containing calendar information which is listed below:

  • date in the form “month/day/year”
  • month
  • year
  • day of week
  • abbreviated and full names of weekday and month

Program 1: 

php




<?php
 
// PHP program to implement cal_from_jd()
// and convert date to the CAL_GREGORIAN
 
 
$input = unixtojd(mktime(0, 0, 0, 8, 16, 2016));
print_r(cal_from_jd($input, CAL_GREGORIAN));
?>


Output:

Array
(
    [date] => 8/16/2016
    [month] => 8
    [day] => 16
    [year] => 2016
    [dow] => 2
    [abbrevdayname] => Tue
    [dayname] => Tuesday
    [abbrevmonth] => Aug
    [monthname] => August
)

Program 2: 

php




<?php
 
// PHP program to implement cal_from_jd()
// and convert date to the CAL_JEWISH calendar
$today = unixtojd(mktime(0, 0, 0, 6, 20, 2007));
 
print_r(cal_from_jd($today, CAL_JEWISH));
?>


Output:

Array
(
    [date] => 11/4/5767
    [month] => 11
    [day] => 4
    [year] => 5767
    [dow] => 3
    [abbrevdayname] => Wed
    [dayname] => Wednesday
    [abbrevmonth] => Tammuz
    [monthname] => Tammuz
)

Related Articles:

Reference: http://php.net/manual/en/function.cal-from-jd.php

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS