get days difference betwenn two date 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

Was this helpful?

0 / 0

Leave a Reply 0

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