Calendar Functions in PHP: Part 5

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 JDToJulian  function

It converts a Julian day count to Julian calendar date in the from of "Month/Day/Year".

Syntax

jdtojulian (jd)


Parameters in
JDToJulian function

It contains one parameter.
 

Parameter Description
jd It specifies Julian day count as integer.

Example of JDToJulian function

<?
php

$daycount=juliantojd(12,26,2012);

echo $daycount ."</br>";

$jdday=jdtojulian($daycount);

echo $jdday;

?>

Output

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

PHP Calendar JDToUnix  function


It converts Julian day count to Unix timestamp. Basically this function will return a Unix time stamp corresponding to the given Julian date. This function returns false if the given Julian day count is not in Gregorian date (must be 1970 -2037).

Syntax

jdtounix (jd)


Parameters in
JDToUnix  function

It contains one parameter.
 

Parameter Description
jd It specifies Julian day count as integer.

Example of JDToUnix function

<?php

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

$unixtime=jdtounix($jdays);

echo $unixtime;

?>

Output

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

PHP Calendar JewishToJD  function


It converts Jewish calendar to Julian day count and this function can handle dates all the way back to the year 1 (3761 B.C).

Syntax

jewishtojd (month, day, year)


Parameters in
JewishToJD  function

It has three parameters and all three are required.
 

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

Example of JewishToJD function

<?php

$d=jewishtojd(12,26,2012);

echo $d;

?>

Output

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

PHP Calendar JulianToJD  function


It converts a Julian calendar date to Julian day count and the valid range of this function is 4713 B.C to 9999 A.D (according to Julian date).

Syntax

juliantojd (month, day, year)

 

Parameters in JulianToJD function

It has three parameters and all three are required.
 

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

Example of JulianToJD function

<?php

$days=juliantojd(12,26,2012);

echo $days;

?>

Output

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

PHP Calendar UnixToJD  function


It converts Unix timestamp to Julian day count; basically it returns the Julian day for a Unix timestamp (seconds since 1.1.1970).

Syntax

unixtojd (timestamp)


Parameters in
UnixToJD function

Contains one parameter and it is an optional parameter..
 

Parameter Description
timestamp It specifies a Unix timestamp.

Example of UnixToJD function

<?php

$d=unixtojd();

echo $d;

?>

Output

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


Similar Articles