get days difference betwenn two date symfony

  date, datetime, diff, php, symfony

I want to get days difference between endDate and startDate of an object :

    $totaldays = ($booking->getEndDate()->diff($booking->getStartDate()) + 1) 

return $this->render('test.html.twig',[
            'dayDiff'         => $dayDiff,
        ]);

this return an error : Notice: Object of class DateTime could not be converted to int

Source: Symfony Questions

LEAVE A COMMENT