I am trying to create an entity using date as primary key. The problem is that Symfony cannot convert the DateTime that I use to a string to enter it in IdentityMap. I get the following error while saving an object:
Catchable Fatal Error: Object of class DateTime could not be converted to string in..
I use this code in an object :
protected $date;
The error appears in the repository. :
$em = $this->getEntityManager(); $currentData = new CurrentData(); ... $currentData->setDate(new \DateTime($dateStr)); ... $em->persist($currentData); $em->flush();
How can I solve this problem? Thanks.
source share