我有两个名为
的变量 $monthly_bill = 1200
和
2016-09-18 480 // Joined 18th and month end 30th = 12 days * (1200 / 30)
2016-10-01 1200
2016-11-01 1200
2016-12-01 1200
2017-01-01 1200
现在我想用月结单显示从加入日期到今天日期的所有月份。例如,循环应显示以下结果:
interact('#draggable').draggable({
inertia: true,
onmove: function() {},
onend: function() {}
});
如何使用php循环显示这个?
答案 0 :(得分:0)
//cal_days_in_month : Return the number of days in a month for a given year and calendar
----------
<?php
$join_date="2016-09-18";
$begin = new DateTime($join_date); // value is : 2016-09-18
$monthly_bill = 1200;
$date=$begin->format('d');
$month=$begin->format('m');
$year=$begin->format("Y");
$ndays=cal_days_in_month(CAL_GREGORIAN,$month,$year);
if($date>1)
{
$totaldays=$ndays-$date;
}
else{
$totaldays=$ndays;
}
$paidbill=$totaldays * ($monthly_bill / $ndays);
echo $paidbill."<br/>";
?>