php – DateInterval into Integer

php – DateInterval into Integer

Actually you are using the object for calculation. You need to get the days and use that for calculation Use like this:

$date1 =  new DateTime($t1);
$date2 =  new DateTime($t2);
$diff = $date1->diff($date2);
$days = $diff->format(%a);

$total = $price * $days;

Try this

$date1 =  new DateTime($t1);
$date2 =  new DateTime($t2);
$diff = $datetime1->diff($datetime2);
$interval =  $diff->format(%a);

$total = $price * $interval;

I have assigned difference to $interval

php – DateInterval into Integer

Leave a Reply

Your email address will not be published. Required fields are marked *