Calendar Function in PHP: Part 4

Introduction

In this tutorial you will learn how to use PHP calendar functions. The PHP calendar functions are used to implement various types of calendar formats. Here I will explain some calendar functions and I am also describing some PHP calendar functions in PART 1 and  PART 2.

PHP Calendar JDMonthName  function

It returns the current month name as a string.

Syntax

jdmonthname (jd, mode)


Parameters in
JDMonthName  function


It has two parameters and the jd parameter is required and the mode parameter is optional. 
 

Parameter Description
jd It specifies Julian day.
day It specifies which calendar to convert the Julian day count, it have different mode.
    0 (zero)- means Gregorian (Jan , Feb, Mar etc) name will be returns.
    1 (one )- means Gregorian (January , February, March etc) name will be returns.
    2 (two )- means   Julian     (Jan , Feb, Mar etc) name will be returns.
    3 (three)- means Julian      (Jan , Feb, Mar etc) name will be returns.
    4 (four)- means Jewish       (Tishri , Heshvan, Kislev  etc) name will be returns.   
    5 (five)- means French Republican (Vendemiaire , Brumarie, Frimarie etc) name will be returns.

Example of JDMonthName function

<?php

$jday=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));

echo(jdmonthname($jday,1))."</br>";

echo(jdmonthname($jday,4));

?>

Output

jd-month-name-calendar-function-in-php.jpg

PHP Calendar JDToFrench  function

It converts a Julian day count to French Republican calendar date.

Syntax

jdtofrench (jd)


Parameters in
JDToFrench function

It has one parameter.
 

Parameter Description
jd It specifies Julian day count as integer.

Example of JDMonthName function

<?php

$date=jdtofrench(2380211);

echo $date;

?>

Output

jd-to-french-calendar-function.jpg

PHP Calendar JDToGregorian  function

It converts a Julian day count to a Gregorian calendar date.

Syntax

jdtogregorian (jd)


Parameters in
JDToGregorian function

It contains one parameter.
 

Parameter Description
jd It specifies Julian day count as integer.

Example of JDToGregorian function

<?php

$jdays = gregoriantojd(12,24,2012);

echo($jdays . "<br />");

 

$gregorian = jdtogregorian($jdays);

echo($gregorian);

?>

Output

jd-to-gregorian-calendar-function-in-php.jpg

PHP Calendar JDToJewish function

It converts a Julian day count to a Jewish calendar date.

Syntax

jdtojewish (jd, hebrew, fl)


Parameters in
JDToJewish function

It has one parameter.
 

Parameter Description
jd It specifies Julian day count as integer.
hebrew It it set true, returns string based format.
fl It specifies hebrew output format.
 Available formats are:
      1- CAL_JEWISH_ADD_ALAFIM_GERESH
      2- CAL_JEWISH_ADD_ALAFIM
      3- CAL_JEWISH_ADD_GERESHAYIM

Example of JDToJewish function

<?php

echo(jdtojewish(gregoriantojd(12,24,2012)) . "<br />");

echo(jdtojewish(gregoriantojd(12,24,2012),true));

?>

Output

jd-to-jewish-calendar-function-in-php.jpg