Reputation: 1633
I am having a problem with Time column type : i have this part of my entity "Match" :
/**
* @ORM\Column(type="date")
*/
private $creationDate;
/**
* @ORM\Column(type="time",nullable=true)
*/
private $creationTime;
And every time i try to persist the entity i get the error :
Error: Call to a member function format() on string in TimeType.php
This is the part where i fill the CreationTime :
$time = date("H:i:s",strtotime(date("Y-m-d H:i:s")));
$Match->setCreationTime($time);
I tried to check the TimeType.php file and i found out that this function is the source of the problem :
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return ($value !== null)
? $value->format($platform->getTimeFormatString()) : null;
}
to be more sure i checked the AbstractPlatform class and found out that the member method getTimeFormatString always returns this string : 'H:i:s'.
So any body can help ?
Upvotes: 4
Views: 7255
Reputation: 35973
try to use this:
$Match->setCreationTime(new \Datetime());
Upvotes: 1