I’m trying to save a date (user’s birthday).
$values['name'] = $request->get('name');
$values['fbid'] = $request->get('fbid');
$values['birthdate'] = date("Y-m-d", $request->get('birthdate'));
$em = $this->getDoctrine()->getEntityManager();
$user = new User();
$user->setName($values['name']);
$user->setFbId($values['fbid']);
$user->setBirthdate($values['birthdate']);
$em->persist($user);
$em->flush();
This is however not working. I’m not seeing any errors. What could be wrong? When I delete the setter for the birthday, the user gets inserted into the database perfectly.
Edit:
/**
* @ORM\Column(type="date", nullable=true)
*/
protected $birthdate;
/**
* Set date
*
* @param date $birthdate
*/
public function setBirthdate($birthdate)
{
$this->birthdate = $birthdate;
}
Try setting
To
Or look into how you can create a DateTime to pass to doctrine