lundi 21 janvier 2019

For loop 15th day and last day of the current month php

i have this date, I want to increment this date by 15th day of the month and end day of the month base on the charge_installment value.

this question is different from this section > How to get every 15th and last day of the month in PHP

$date = '21-JAN-19';
$chrg_installment = 4;

for ($i=1; $i <= $chrg_installment ; $i++) { 
    echo $date;
}

output of the loop.

21-JAN-19 21-JAN-19 21-JAN-19 21-JAN-19

the correct output will be:

31-JAN-19 15-FEB-19 28-FEB-19 15-MAR-19

Aucun commentaire:

Enregistrer un commentaire