Trying to figure out how to use the gregorianToJd function in php to determine the julian date when a user inputs a specific date in time. i have my code to where it will do this without using the function, but now i need to show it using the function.

Here's my code

<?php
$months = $_POST['months'];
$days = $_POST['day'];
$years = $_POST['years'];


//associative array for Julian Date
$monthdays=array( 'Jan'=>0, 'Feb'=>31, 'Mar'=>59, 
	'Apr'=>90, 'May'=>120, 'Jun'=>151, 'Jul'=>181, 'Aug'=>212,
	'Sep'=>243, 'Oct'=>273, 'Nov'=>304, 'Dec'=>334);

$monthname=array( 'Jan'=>'January', 'Feb'=>'Febuary', 'Mar'=>'March', 
	'Apr'=>'April', 'May'=>'May', 'Jun'=>'June', 'Jul'=>'July', 
	'Aug'=>'August', 'Sep'=>'September', 'Oct'=>'October', 'Nov'=>'November', 'Dec'=>'December');

print"Date:$monthname[$months] $days, $years<br>";

$jd = gregoriantojd($months,$days,$years);
$mJulianDate=$monthdays[$months] + $days;
	print "Calculated without using a PHP Function:$mJulianDate";
	print "<br>Calculated using a PHP Function:$jd";
	
if ($years % 4 == 0) {

		//Divisible by 4 but not 100
		if ($years % 100 != 0) {
		echo "<br>$years is a leap year.";
		}
		//Divisible by 4 and 100 and 400
		else if ($years % 400 == 0) {
		echo "<br>$years is a leap year.";
		}
		//4 and 100 but not 400
		else {
		echo "<br>$years is not a leap year.";
		}
	}
	// It is not divisible by 4.
	else {
		echo "<br>$years is not a leap year.";
	}
 	            
?>
Member Avatar for diafol

I don't see what your problem is. You've written your own code and you've used the php function. So what do you want?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.