Hello everybody, i m working on PHP and MS Access DB. actually i have the date problem. Pls view my code below:
$completedate=$query->fields['ComplDate']->Value;
$compdate=date('d-m-Y',$completedate);
$currentdate=strtotime("now");
$currdate=date('d-m-Y',$currentdate);
if($compdate=<$currdate)
{
print "<td width='8%' style='BORDER-RIGHT: #009900 1px solid; BORDER-TOP: #009900 1px solid; BORDER-LEFT: #009900 1px solid; BORDER-BOTTOM: #009900 1px solid' align='center'><font size='2'>" ."Completed"."</font></td>";
}
else{
print "<td width='8%' style='BORDER-RIGHT: #009900 1px solid; BORDER-TOP: #009900 1px solid; BORDER-LEFT: #009900 1px solid; BORDER-BOTTOM: #009900 1px solid' align='center'><font size='2'>"."Ongoing"."</font></td>";
}
Infact i want to print "Completed" if the ComplDate from database is less than or equal to todays date and vice versa. But the problem is that it doesnt give me the appropiate output. Pls help me where am i mistaken?
Hi,
To set a php variable to the current date all you need is:
[php]
$currentdate = date("Y-m-d"); // this will give 2007-10-04
[/php]
Check out the manual on the
date function and you'll see that you can make the variable format match the data format. This should help you out.
The other ting to do to checck the format is to simply echo them both to the browser so that you can see if they match and what differences there are, this will help you to track down any formatting issues.
[php]
$currentdate = date("Y-m-d"); // this will give 2007-10-04
echo $currentdate ;
$completedate=$query->fields['ComplDate']->Value;
echo $completedate ;
[/php]
Have a play around with that and if you get stuck post back.
Cheers
nathj