I have a problem saving the data in the database . It saves them as 1970-01-01 , invalid date . I would read them as dd-mm-yyyy and convert them to the database in yyyy-mm-dd .
my model
public function behaviors()
{
return [
[
'class' => AttributeBehavior::className(),
'attributes' => [
attribute ['created','updated']
ActiveRecord::EVENT_BEFORE_INSERT => ['data_arrivo','data_part'],
ActiveRecord::EVENT_BEFORE_UPDATE => 'data_arrivo', 'data_part'
],
'value' => function ($event) {
return date('Y-m-d', strtotime($this->data_part));
},
],
];
Any suggestions?