Have been trying to implement the pmt function used in excel into php. I have the formula but the calculations are showing incorrect.
Its 6% interest rate for period of 30 years, final value being 833333.
The right answer should be 10,541.
payments are due at the end of the period so the type is zero and present value is zero.
$pv = 0;
$fv = 833333;
$i = 0.06/12;
$n = 360;
$pmt = (($pv - $fv) * $i )/ (1 - pow((1 + $i), (-$n)));
The formula that I use in PHPExcel to reflect MS Excel's formula is:
$PMT = (-$fv - $pv * pow(1 + $rate, $nper)) / (1 + $rate * $type) / ((pow(1 + $rate, $nper) - 1) / $rate);
Which returns the same result as MS Excel when I use
=PMT(6%/12, 360, 0, 833333, 0)
And which returns a result of -10540.755358736 (the same as MS Excel) when I use