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.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP cal_from_jd Function: Convert Julian Day to a Supported Calendar

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
)
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

date-conversionjulian-day
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.