hi i'm trying to get the days between 2 dates. this is my coding:
<?php
$Cur_date = date("Y-m-d");
$Warranty = intval($row_Recordset1['Hardware_warranty']);
$timestamp = strtotime($row_Recordset1['Pur_date']);
$newtimestamp = strtotime("+".$Warranty." years", $timestamp);
$newtimestamp = date('Y/m/d', $newtimestamp) ;
if($Cur_date< $newtimestamp)
{
$interval = $Cur_date->diff($newtimestamp);
echo "Valid"."\n\n\n".$interval->y . " years, " . $interval->m." months, ".$interval->d." days "." left";
}
else if ($Cur_date > $newtimestamp)
{
echo "Expired" ;
}
?>
but an error came out:
Fatal error: Call to a member function diff() on string in C:\xampp\htdocs\Warranty\WarrantyStatus.php on line 155
please help me thank you
not a duplicate of How to calculate the difference between two dates using PHP?
i'm having a different problem here,do i need to declare something beforehand?