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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

852163200

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

1511222400

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



My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.