Dear Friends,
I created Table in PHP. Columns are
SrNo. ---- Tender Detail----- Last Date----- Remaining Days ---------- Status(Pending/Proceded)
I have Database in mysql.
I get "last date" from database and minus with Current date. But i tried there is any problem please, check.
Code is below
<?php
function dateDifference($date_1 , $date_2 , $differenceFormat = '%a' )
{
$datetime1 = date_create($date_1);
$datetime2 = date_create($date_2);
$interval = date_diff($datetime1, $datetime2);
return $interval->format($differenceFormat);
}
include "headeradmin.php";
include "conn1.php";
//$sql=SELECT DATE_FORMAT(ldate,GET_FORMAT(DATE,'EUR') FROM tentb);
//$sql="SELECT DATEDIFF(CURDATE(),ldate) AS DiffDate"
$sql="SELECT id,edate,cdetail,tdetail,DATE(ldate) AS ldate FROM tentb ";
$result=$conn1->query($sql);
?> <div id="userdiv"> <ul> <li> User Name:
<li> Status:
<li> Logout: <a href="adminlogin.php">Click here</a> </ul> </div> <br> <div id="container"> <h2>Current Date: <?php echo date('Y-M-d') ?></h2> <div id="contant"> <div id="contantleft"> <table align= right> <th>Sr# </th> <th>Client Detail </th> <th>Tender Description </th> <th>Last Date</th> <th>Remaining Days</th> <th>Status</th> <?php
$i=1;
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>".$i."</td>";
echo "<td>".$row ['cdetail']. "</td>";
echo "<td>".$row ['tdetail']. "</td>";
echo "<td>".$row['ldate']."</td>";
echo "<td>".dateDifference('edate','ldate',$differenceFormat = '%d' )."</td>";
echo"</tr>";
$i++;
}
?> </table> </div><!----Contantleft End ----->
i received
Fatal error: Call to a member function format() on a non-object in C:\wamp\www\SprintWeb\adminfrm.php on line 12
and
Warning: date_diff() expects parameter 1 to be DateTimeInterface, boolean given in C:\wamp\www\SprintWeb\adminfrm.php on line 10