I've done a function for incremnting dates
here is the following:
function periode($var, $i3, $i2)
{
if($var=='52')
{
return "+ ".$i3." week";
}
if($var=='26')
{
return "+ ".($i3+2+$i3)." week";
}
if($var=='12')
{
return "+".$i3." month";
}
if($var=='6')
{
return "+ ".($i3+$i2)." month";
}
if($var=='4')
{
return "+ ".($i3+2*$i2)." month";
}
if($var=='2')
{
return "+ ".($i3+5*$i2)." month";
}
if($var=='1')
{
return "+ ".($i2)." year";
}
}
the trouble is that when I use that function like that:
if($pay_periodicity==26){$i3=0;}elseif($pay_periodicity==4){$i3=0;}elseif($pay_periodicity==6){$i3=0;}else{$i3=0;}; $i2=0;
$montant_echeance = round($montant_du / $nombre_echeances, 2);
$reste=$montant_du ;
while($i2 <= $nombre_echeances)
{
echo periode($pay_periodicity,$i3,$i2);
if ($i2 == $nombre_echeances)
{
$montant_echeance = $reste;
$reste = 0;
}
$date = date("d-m-Y",strtotime((($debut)."".periode($pay_periodicity,$i3,$i2)."")));
$chaine .= "<tr>
<td>$montant_du</td>
<td>".$date."</td>
<td>$montant_echeance</td>
<td>$reste</td></tr>";
$reste = $reste-$montant_echeance;
$i2++;
++$i3;
}
$chaine .="</table>";
print "$chaine";
}
after the 25th $i2, it display date like that:
01-01-1970
I really do not understand why we can not increment more than 25 years.
Any help or advice will be much appreciated.
Kind regards.
SP.