0

hi guys,
i have confusion about comparing dates in php. i want to compare birth date with current date.
here is my code. i hope u will me to solved out this problem.
thanks

<?php //code for get values from session
session_start();

if(isset($_SESSION['I'])){
//this code will get email id from session
$myeid = $_SESSION['I'];
echo $myeid . "-<br>";
}
else{
header("Location: loginimgs.php");}

if(isset($_SESSION['NEED'])){
//this code will get password from session
$mypass = $_SESSION['NEED'];}
else{
header("Location: loginimgs.php");}

?>
<?php //code for get value of usercode from database
error_reporting(0);
$myuname = "";
mysql_connect("localhost", "root", "") or die(mysql_error()); 
mysql_select_db("dummy1") or die(mysql_error());
$check = mysql_query("SELECT * FROM members WHERE email = '$myeid'")or die(mysql_error()); 
while($info = mysql_fetch_array($check))
{
	if ($myeid == $info['email'])
	{
		$myuname = $info['username'];
		$mycode = $info['usercode'];
		
	}
}
$userscode = $mycode;

?>
<?php
error_reporting(0);
mysql_connect("localhost", "root", "") or die(mysql_error()); 
mysql_select_db("dummy1") or die(mysql_error());
$checky = mysql_query("SELECT * FROM acountseting")or die(mysql_error());

while($chec = mysql_fetch_array($checky)) 
{
	if($chec['usercode'] == $mycode)
	{
		$date2 = $chec['birthday'];
		 
		$name = $chec['fnm'];
		
		echo $date2;
	}

}


$date1 = date("Y-m-d");
echo "<br>" . $date1 . "<br>";


$today = strtotime($date1);
$expiration_date = strtotime($date2);

if ($expiration_date > $today) {
     $valid = "yes";
} else {
     $valid = "no";
}

echo "<br>" . $valid . "<br>";

$dateCmp=dateDiff("-",$date2,$date1);
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
echo $end_date . "<br>";
echo $start_date;
return $end_date - $start_date;

}

print $name . "'s birthday on" . $dateCmp;
?>
3
Contributors
3
Replies
7
Views
6 Years
Discussion Span
Last Post by ujjval dave
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.