Cómo poner un borrowdate en mi cálculo multas

Quiero ingresar un $borrowdate en el código porque creo que es por eso que mis penalizaciones actualizan continuamente un código incluso si se devuelve. Esta es la mesa 27 de agosto La fecha es el 27 de agosto y las sanciones continúan continuamente.

 $borrowdate = new Datetime($row['date_return']); // This code $returndate = new Datetime($row['due_date']); $currentdate = new Datetime(); $returndate->setTime(0,0); $currentdate->setTime(0,0); $interval = DateInterval::createFromDateString('1 day'); $period = new DatePeriod($returndate, $interval, $currentdate); $weekendDays = 0; $totalDays = 0; foreach ( $period as $p ) { $totalDays++; if($p->format( "w" )==0) $weekendDays++; } echo "

Total days: $totalDays

Weekend days: $weekendDays

"; $fines = ($totalDays - $weekendDays) * 15; echo "₱ ". $fines; $fi = $row['borrow_details_id']; mysqli_query($dbcon,"update borrowdetails set fines='$fines' where borrow_details_id = '$fi'");

Acabo de crear un setTime para Borrowdate y reemplazo el $currentdate en

$period = new DatePeriod($returndate, $interval, $currentdate);

DENTRO

$period = new DatePeriod($returndate, $interval, $borrowdate);

 $borrowdate = new Datetime($row['date_return']); $returndate = new Datetime($row['due_date']); $currentdate = new Datetime(); $returndate->setTime(0,0); $currentdate->setTime(0,0); $borrowdate->setTime(0,0); $interval = DateInterval::createFromDateString('1 day'); $period = new DatePeriod($returndate, $interval, $borrowdate); $weekendDays = 0; $totalDays = 0; foreach ( $period as $p ) { $totalDays++; if($p->format( "w" )==0) $weekendDays++; } echo "

Total days: $totalDays

Weekend days: $weekendDays

"; $fines = ($totalDays - $weekendDays) * 15; echo "₱ ". $fines; $fi = $row['borrow_details_id']; mysqli_query($dbcon,"update borrowdetails set fines='$fines' where borrow_details_id = '$fi'");