I know there are a lot open topics for this question but I wasn't able to find any solution.
I am trying to get my object of class from entity in symfony via getter and I have trouble getting datetime field because it can not be converted to string.
$date = new \DateTime();
$get->getBirthDate(\DateTime::createFromFormat('Y-m-d', $date)),
I think this is proper way but it does not work.
This code works:
$get->getBirthDate = $date->format('Y-m-d'),
but
object of class declared dynamically