How to set a date in Doctrine 2?

前端 未结 2 702
旧时难觅i
旧时难觅i 2021-01-07 16:56

I have a field named \"birthday\" in doctrine entity.

I would like to create an object to add to database using doctrine.

Inside the controller :

<         


        
2条回答
  •  时光取名叫无心
    2021-01-07 17:29

    $name = "John Alex";
    $birthday = "11-11-1990"; // I changed this
    $student = new Student();
    $student->setName($name);
    $student->setBirthday(new \DateTime($birthday)); // setting a new date instance
    // ...
    

提交回复
热议问题