0

My name is Eben and I'm a beginner in php. I've been getting this error message "Notice: A non well formed numeric value encountered in C:\wamp64\www\Project\FeePayment.php on line 145". This is the code;

$datetime1 = new DateTime($orderdate);
                        $datetime2 = new DateTime($currdate);

                        $interval = date_diff($datetime1, $datetime2);
                        $interval->format('%m months');
                        $months_diff = $interval->format('%m months');
                                                    
                        for($i = 1; $i <=($months_diff+1); $i++){
                            $totalFees = $fees + $totalFees;

Please help

AbraCadaver
  • 78,200
  • 7
  • 66
  • 87
  • 1
    `$months_diff` will be a piece of text saying something like `3 months` - because that's how you told it to format that value. Therefore you can't do maths on it and add 1 to it (as in `$months_diff+1`) - I assume that's where the error comes from, although you didn't mention the exact line – ADyson Sep 30 '21 at 22:23
  • Okay bro so what do you propose i do instead. – Kojo Yeboah Oct 01 '21 at 12:59
  • Change the call to $interval->format so it outputs only a number - isn't that obvious? If you want to do maths you have to have 2 numbers. – ADyson Oct 01 '21 at 13:03

0 Answers0