hello
in a form i have a date in format 'dd/mm/yyyy'
i use entity and i want save the date in sql with model
i do in my model
Code:
$myEntity = new TheEntity($data);
if ($this->save($myEntity))
this send me an error
DateTime::__construct(): Failed to parse time string (19/03/2016) at position 0 (1): Unexpected character
i have create a setter in my entity
Code:
protected $dates = ['date_naissance'];
public function setDateNaissance($date)
{
if (empty($date)) {
$this->attributes['date_naissance'] = null;
return $this;
}else{
$this->attributes['date_naissance'] = date('Y-m-d', strtotime(str_replace('/', '-', $date)));
return $this;
}
}
but the setter isn't call before the error