Thursday, October 9, 2025
HomeLanguagesPHP | jdtogregorian() Function

PHP | jdtogregorian() Function

The jdtogregorian() function is a built-in function which converts a Julian Day Integer to Gregorian date. The function accepts a Julian Day integer and returns the converted Gregorian Date in $month / $day / $year.

Syntax:

jdtogregorian($jd)

Parameters: The function accepts one mandatory parameter $jd which specifies the Julian day.

Return Value: The function returns the Gregorian date. The return format of the date is $month / $day / $year.

Examples:

Input : 2458209
Output : 3/31/2018

Input : 2458236
Output : 4/27/2018

Below programs illustrate the jdtogregorian() function.

Program 1: The program below illustrate the use of jdtogregorian() function.




<?php
// PHP program to demonstrate the
// use of jdtogregorian() function 
  
// converts date to julian integer 
$jd = gregoriantojd(3, 31, 2018);
  
// converts the Julian day to Gregorian date
$date = jdtogregorian($jd);
  
// prints the date
echo ($date), "\n"; 
  
?>


Output:

3/31/2018

Program 2: The program below shows the output when an invalid Julian day integer is passed.




<?php
// PHP program to demonstrate the output
// of jdtogregorian() function when 0 is 
// passed as Julian Day, which is invalid
  
// converts the Julian day to Gregorian date 
// invalid hence outputs 0/0/0 
$date = jdtogregorian(0);
  
// prints the date
echo ($date), "\n"; 
  
?>


Output:

0/0/0

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

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32342 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6712 POSTS0 COMMENTS
Nicole Veronica
11876 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11937 POSTS0 COMMENTS
Shaida Kate Naidoo
6833 POSTS0 COMMENTS
Ted Musemwa
7092 POSTS0 COMMENTS
Thapelo Manthata
6786 POSTS0 COMMENTS
Umr Jansen
6789 POSTS0 COMMENTS