search

Home  >  Q&A  >  body text

symfony - Fatal error: Call to a member function format() on a non-object

Fatal error: Call to a member function format() on a non-object in /var/www/test/openmysfony/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateType.php on line 44

This problem is a bit strange.. Has anyone else encountered it? One is correct and the other is wrong in both the local environment and the server environment.

世界只因有你世界只因有你2738 days ago1035

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-05-16 16:48:05

    It is very typical that when instantiating an object, there is no check whether the instantiation is successful, and then the return value is directly called as an object. If there is no error, it is good luck, and if there is an error, it is better luck.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 16:48:05

    When saving time, you must first convert the passed in time into an object and then save it.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 16:48:05

    $now_time = new Datetime();
    $product->setCreateTime($now_time);

    reply
    0
  • Cancelreply