public function beforeValidate() { if ($this->date_begin != null) { $new_date_begin = date('Y-m-d', strtotime($this->date_begin)); $this->date_begin = $new_date_begin; } if ($this->date_end != null) { $new_date_end = date('Y-m-d', strtotime($this->date_end)); $this->date_end = $new_date_end; } return parent::beforeValidate(); }