using php 5.5.9 . I have Tranche Entity, and it has a date attribute. What I want is to get number of rows matching a criteria; having date gt/lt current date ,so I created a twig extension, this is my code: following this this
public function e()
{
$criteria = new \Doctrine\Common\Collections\Criteria();
$date=date('Y-m-d');
$criteria->where($criteria->expr()->lt('date',$date));
$result=$this->em->getRepository('OCUserBundle:Tranche')->matching($criteria);
return count($result);
}
My problem is that I can't compare dates no matter what I tried.
This is the error:
DateType.php line 53: Error: Call to a member function format() on a non-object
I've searched a lot and tried many suggestions, not working and I'm stuck. What's happening and thank you in advance.