$end
is currentday and because of that it will calculate a fine even if currentdate is less than duedate.
What you need is a if currentday is more than duedate, then calculate the fine.
$currentdate = date('Y/m/d');
$start = new DateTime($returndate=$row['due_date']); <-- from database
$end = new DateTime($currentdate);
if(strtotime($currentdate) > strtotime($returndate)){
$days= $start->diff($end, true)->days;
$fines = $days > 0 ? intval(floor($days)) * 10 : 0;
}
strtotime() will convert a date in string format to UNIX time (integer).
You can test the code here: https://3v4l.org/fl3IM
Edit:
Method 1.
$currentdate = date('Y/m/d');
$start = new DateTime($returndate=$row['due_date']); <-- from database
$end = new DateTime($currentdate);
$fines = 0;
if(strtotime($currentdate) > strtotime($returndate)){
$days= $start->diff($end, true)->days;
$fines = $days > 0 ? intval(floor($days)) * 10 : 0;
}
Now it will show a fine of 0 until someone has passed due date. (may look cluttered in the page)
Method 2.
$currentdate = date('Y/m/d');
$start = new DateTime($returndate=$row['due_date']); <-- from database
$end = new DateTime($currentdate);
if(strtotime($currentdate) > strtotime($returndate)){
$days= $start->diff($end, true)->days;
$fines = $days > 0 ? intval(floor($days)) * 10 : 0;
}
//some other code I guess...
if(isset($fines)) echo $fines;
Here $fines is not set and will not be echoed unless someone is passed due date. This method probably will look the best on the page.
But I don't know exactly how your page is set up.