I l@ve RuBoard Previous Section Next Section

unixtojd

int unixtojd([int timestamp]) 

Converts a UNIX timestamp to a Julian day count.

Returns:

Julian day count

Description:

unixtojd() converts a UNIX timestamp to a Julian day count. If no timestamp is given, the function returns the Julian day count for the current timestamp.

Warning:

As of PHP 4.0.4, this function behaves oddly if given a timestamp less than 0. Filtering the input to ensure that a valid timestamp is being passed to the function is a good idea.


Version:

Available in PHP 4.0.0 RC 2

See also:

To convert a Julian day count to a UNIX timestamp date:

jdtounix() 

To convert a Julian day count to another calendar system, see the jdto* functions

Examples:

Display the Julian day count that corresponds to the UNIX epoch
echo 'The Julian day count for the start of the UNIX epoch is ' .. unixtojd (1); 

For more information on the UNIX epoch, visit www.foldoc.org and search for epoch.

Ensure that the timestamp passed to unixtojd() is valid
function filtered_unixtojd ($timestamp = FALSE) {
    if ($timestamp < 0 || $timestamp > 2138832000) 
        return FALSE; 

    if ($timestamp) 
        return unixtojd ($timestamp); 

    return unixtojd (); 
} 

echo filtered_unixtojd (99232000); 
    I l@ve RuBoard Previous Section Next Section