Tuesday, November 19, 2024
Google search engine
HomeLanguagesPHP | jdtounix( ) Function

PHP | jdtounix( ) Function

The jdtounix() function in PHP is a built-in function which is used to convert a Julian day date into a Unix Timestamp. This function returns a Unix timestamp corresponding to the Julian Day which is used as a parameter or it returns FALSE if entered date is not inside the Unix epoch i.e Gregorian years between 1970 and 2037 or 2440588 <= Julian day date <= 2465342.

The jdtounix() function returns time according to the Universal Time Coordinated(UTC).

Syntax:

jdtounix($jd)

Parameters: The jdtounix() function in PHP accepts only one parameter $jd. This parameter specifies a Julian Day number between 2440588 and 2465342.

Return Value: It returns a Unix timestamp corresponding to the Julian Day which is used as a parameter or it returns FALSE if entered date is not inside the Unix epoch.

Errors And Exception:

  1. The Julian Date used as a parameter must be in the range of 2440588 – 2465342.
  2. The jdtounix() function ignores the decimal part of the julian day count and therefore it may give improper results in many cases.

Examples:

Input : $julian_date = gregoriantojd(01, 02, 1997);
        echo jdtounix($julian_date);
Output : 852163200

Input : $julian_date = gregoriantojd(11, 21, 2017);
        echo jdtounix($julian_date);
Output : 1511222400

Below programs illustrate the jdtounix() function:

Program 1:




<?php
  
// converting Gregorian date to Julian date
$julian_date = gregoriantojd(01, 02, 1997);
  
// Converting Julian date to Unix Timestamp
echo jdtounix($julian_date);
  
?>


Output:

852163200

Program 2:




<?php
  
// converting Gregorian date to Julian date
$julian_date=gregoriantojd(11, 21, 2017);
  
// Converting Julian date to Unix Timestamp
echo jdtounix($julian_date);
  
?>


Output:

1511222400

Reference:
http://php.net/manual/en/function.jdtounix.php

RELATED ARTICLES

Most Popular

Recent Comments