PHP cal_from_jd() Function
The PHP cal_from_jd() function converts the Julian day count into a date of the specified calendar. Supported calendars by this function are CAL_GREGORIAN, CAL_JULIAN, CAL_JEWISH and CAL_FRENCH.
Syntax
cal_from_jd(julian_day, calendar)
Parameters
julian_day |
Required. Specify a Julian day count as integer. |
calendar |
Required. Specify the Calendar to convert to. Must be one of the following values:
|
Return Value
Returns an array containing calendar information which are listed below:
- date in form "month/day/year"
- month
- day
- year
- day of week (dow) - ranges from 0 (Sunday) to 6 (Saturday).
- abbreviated and full names of weekday and month
Exceptions
NA.
Example:
The example below shows the usage of cal_from_jd() function.
<?php //getting a Unix timestamp for a date then //converting it into Julian day count $jd = unixtojd(mktime(0, 0, 0, 8, 16, 2016)); //convering the Julian day count into //a date of the Gregorian calendar print_r(cal_from_jd($jd, CAL_GREGORIAN)); ?>
The output of the above code will be:
Array ( [date] => 8/16/2016 [month] => 8 [day] => 16 [year] => 2016 [dow] => 2 [abbrevdayname] => Tue [dayname] => Tuesday [abbrevmonth] => Aug [monthname] => August )
Example:
Consider one more example where a Julian day count is converted into Jewish calendar type.
<?php //getting a Unix timestamp for a date then //converting it into Julian day count $jd = unixtojd(mktime(0, 0, 0, 8, 16, 2016)); //convering the Julian day count into //a date of the Jewish calendar print_r(cal_from_jd($jd, CAL_JEWISH)); ?>
The output of the above code will be:
Array ( [date] => 12/12/5776 [month] => 12 [day] => 12 [year] => 5776 [dow] => 2 [abbrevdayname] => Tue [dayname] => Tuesday [abbrevmonth] => Av [monthname] => Av )
❮ PHP Calendar Reference