Doctrine 2: Call to a member function format() on a non-object … in DateTimeType.php

前端 未结 4 1780
北海茫月
北海茫月 2020-12-09 15:37

I have a DateTime field:

/**
 * Date time posted
 * @Column(type=\"datetime\")
 */
private $dtPosted;

which is set to a defau

4条回答
  •  感情败类
    2020-12-09 16:26

    I came across a similar problem, but with a time field, and this question and @romanb 's answer helped.

    I was getting the following error, much like the one in the question.

    Call to a member function format() on a non-object in 
    ... /vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/TimeType.php on line 50
    

    The solution was similar, for fields of the time datatype, Doctrine will accept an instance of PHP's DateInterval

    $quizFixture1->setCompletionTime(\DateInterval::createFromDateString('743 seconds'));
    

提交回复
热议问题