PHP cal_from_jd Function: Convert Julian Day to a Supported Calendar
This article explains the PHP cal_from_jd() function, which converts a given Julian Day number into a date according to a specified calendar such as Gregorian, Julian, Jewish, or French, detailing its parameters, return structure, and providing a complete usage example.
The cal_from_jd() function converts a Julian Day number ( $jd ) into a date based on the chosen calendar ( $calendar ). Supported calendar constants are CAL_GREGORIAN , CAL_JULIAN , CAL_JEWISH , and CAL_FRENCH .
Parameters
jd : an integer representing the Julian Day count.
calendar : the calendar constant to which the date should be converted.
Return value
The function returns an associative array containing the date components: month, day, year, day of week (both numeric and textual forms), and month names (both abbreviated and full). The date format in the array is "month/day/year".
Example usage
<?php
$today = unixtojd(mktime(0,0,0,8,16,2003));
print_r(cal_from_jd($today, CAL_GREGORIAN));
?>Running the example produces an array similar to:
Array
(
[date] => 8/16/2003
[month] => 8
[day] => 16
[year] => 2003
[dow] => 6
[abbrevdayname] => Sat
[dayname] => Saturday
[abbrevmonth] => Aug
[monthname] => August
)Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.