Greetings guys, I raise my problem:
I must make a 15% increase to an amount 5 days after the date on which the person had to have paid. A practical example is:
Current Date: 08-30-2017 Payment Date: 08-25-2017 Total = amount + (amount * 0.15)
As you can see, that is what must be fulfilled in my conditions.
I have tried with this:
$hoy = date('d-m-Y');
$fecha_pago = new DateTime($row['fecha_a_pagar']);
$fecha = new DateTime($hoy);
$diff = $fecha->diff($fecha_pago);
$multa = 0;
if($diff->days >= 5 && $diff->invert):
$multa = $row['monto']*0.15;
$total = $row['monto']+$multa;
endif;
It does the increase well, but when I am going to pay an advance fee, eg:
Date today: 08-30-2017
Fee date to pay: 09-12-10
He keeps giving me the increase, he is not comparing the months. Just the days.
what you can do is use the diff method that gives you the difference between two dates. In this case, you could do:
You can use the date_diff() function which returns a DateInterval object with the difference of days, hours, minutes, etc.
Example modified from the PHP documentation: