I search in stackoverflow but i didn't find the answer. I have this error :
Argument 1 passed to App\Entity\Matchs::setDate() must implement interface DateTimeInterface, bool given,
I have this in my fixtures :
$match1 = new Matchs();
$m1->setDescription('Description ')
->setDate(\DateTime::createFromFormat('d-m-Y hh:mm', '25-12-2001 20:30'))
$manager->persist($m1);
So I don't understand why it does not work because I have implemented the DateTimeInterface interface... Thansk for help
The DateTime::createFromFormat
failed do create a DateTime, and in this case return false
.
I belive that problem is the format, instead 'd-m-Y hh:mm'
try 'd-m-Y H:i'
You can see a complete list of you can use in the format here https://www.php.net/manual/en/datetime.format.php.