title: yii2 save date format how 1970-01-01 Database
body: <p>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 .</p>
  
  <p><strong>my model</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>public function behaviors()
  {
      return [
          [
              'class' =&gt; AttributeBehavior::className(),
              'attributes' =&gt; [
                  attribute ['created','updated']
                  ActiveRecord::EVENT_BEFORE_INSERT =&gt; ['data_arrivo','data_part'],
                  ActiveRecord::EVENT_BEFORE_UPDATE =&gt; 'data_arrivo', 'data_part'
              ],
              'value' =&gt; function ($event) {
                  return date('Y-m-d', strtotime($this-&gt;data_part));
              },
          ],
      ];</code></pre>
  </div>
  </div>
  </p>
  
  <p>Any suggestions?</p>