2017-08-27 12 views
0

$borrowdateをコードに入力したいのは、それが返されても私のペナルティが継続的にコードを更新しているからです。これはテーブルAugust 27です。日付は8月27日であり、継続的に罰則が行われています。私の計算の罰金にborrowdateを入れる方法

$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 "<p>Total days: $totalDays</p><p>Weekend days: $weekendDays </p>"; 
$fines = ($totalDays - $weekendDays) * 15; 
echo "₱ ". $fines; 
$fi = $row['borrow_details_id']; 
mysqli_query($dbcon,"update borrowdetails set fines='$fines' where borrow_details_id = '$fi'"); 

答えて

0

私はちょうどBorrowdateのためのsetTimeを作成し、私は

$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 "<p>Total days: $totalDays</p><p>Weekend days: $weekendDays </p>"; 
$fines = ($totalDays - $weekendDays) * 15; 
echo "₱ ". $fines; 
$fi = $row['borrow_details_id']; 
mysqli_query($dbcon,"update borrowdetails set fines='$fines' where borrow_details_id = '$fi'"); 
INTO

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

$currentdate を置き換えます

関連する問題