Canendar Functions in PHP- Part 3

Introduction

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

PHP Calendar FrenchToJD  function

It converts a date from French Republican Calendar to a Julian day count. This routine only converts dates in years 1 through 14.

For example

Gregorian date 22-9-1792 through 22-9-1806.

Syntax

frenchtojd (month, day, year)


Parameters in frenchtojd function

It has three parameters and every parameter is required in this function.
 

Parameter Description
month It specifies month number.
day It specifies day number.
year It specifies year as a number from 1 to14..


Example of frenchtojd function:
 

<?php

$days=frenchtojd(1,20,12);

echo $days;
?>

Output

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

PHP Calendar GregorianToJD  function

It converts a date from Gregorian calendar to Julian calendar. The valid range for Gregorian calendar is 4714 B.C to 9999 A.D.

Syntax
 

gregoriantojd (month, day, year)


Parameters in
 GregorianToJD function


It has three parameters and every parameter is required in this function.
 

Parameter Description
month It specifies month number.
day It specifies day number.
year It specifies year.


Example of 
GregorianToJD function:
 

<?php

$julianday=gregoriantojd(6,12,2005);

echo $julianday;

?>

Output

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

PHP Calendar JDDayOfWeek  function

It returns the day of a week. It can return a string or return an integer value depending on the mode.

Syntax:
 

jddayofweek (jd, mode)


Parameters in
JDDayOfWeek function

It has two parameters.
 

Parameter Description
month It specifies a number (a Julian day count). 
day It specifies what to return (integer or string).
 mode- 0(zero)- returns day of number as integer.
            1(one)- returns day of number as string.
            2(two)- returns day of number as string that contain the abbreviated day of week.


Example of
JDDayOfWeek function:
 

<?php

echodate("d")." ";

echodate("m")." ";

echodate("Y")." ";

echo' <br/>';

echojddayofweek ( cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y")) , 1 );
?>

Output

jd-day-of-week-calendar-function-in-php.jpg 

Up Next
    Ebook Download
    View all
    Learn
    View all