hi im having an error with my code can anyone help me try to fix my problem
the error is
and my code is
the purpose of this code is to compute the rate depending on the date
the error is
Code:
Fatal error: Call to a member function diff() on a non-object in C:\xampp\htdocs\msicfinal\samp.php on line 12
Code:
<?php
/*These look like they are sent via form submit to this program*/
$date1 = '2012-04-01'; // pick up date
$date2 = '2012-05-27'; // return date
$perday=2500;
$permonth=52500;
$perweek=15000;
$datetime1 = ($date1);
$datetime2 = ($date2);
$interval = $datetime1->diff($datetime2); // the math for the difference
$rest = $interval->format('%d days'); // this may contain weeks
$week = intval($rest / 7); // weeks extracted from the above var.
$mon = $interval->format('%m'); // The mon from formatting
$day = intval($rest % 7); // This line MUST STAY to figure number of days
$total = $mon * $permonth + $week * $perweek + $day * $perday;
echo $total . '<br />';
?>
the purpose of this code is to compute the rate depending on the date
Comment