PHP Function Reference

PHP unixtojd() Function



The PHP unixtojd() function converts Unix timestamp to Julian Day count. If no parameter is passed, the function returns the current Julian Day count.

Note: Unix timestamp indicates the number of seconds since midnight of January 1, 1970 (Gregorian Calendar).

Syntax

unixtojd(timestamp)

Parameters

timestamp Optional. Specify a Unix timestamp to convert. If not provided, the function returns the current Julian Day count.

Return Value

Returns a Julian day count as integer, or false on failure.

Exceptions

NA.

Example:

The example below shows the usage of unixtojd() function.

<?php
//getting the current Julian day count
$jd = unixtojd();

//displaying the result
echo "The Julian day integer is: $jd \n";
?>

The output of the above code will be:

The Julian day integer is: 2459452 

Example:

Consider one more example where the Unix timestamp is created using mktime() function then converted into Julian Day count using this 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));

//displaying the result
echo "The Julian day integer is: $jd \n";
?>

The output of the above code will be:

The Julian day integer is: 2457617 

❮ PHP Calendar Reference