Model validate date format

My model when validate input date, convert the format type and it cause trouble…

My form has:


<?php $form = yii\widgets\ActiveForm::begin([

                                'options' => ['class' => ''],

                                'fieldConfig' => ['template' => "{label}\n{input}\n{hint}\n{error}"]

                            ]); ?>

                            

                            <div class="col-md-4"> 

                            <?= $form->field($model, 'startDate')->widget(DatePicker::classname(), 

                                [

                                    'language'      => 'pt-BR',

                                    'dateFormat'    => 'dd/MM/yyyy',

                                    

                                    'clientOptions' => [

                                        'yearRange'     => '2005:+0', 

                                        'defaultDate'   => date('d/m/Y', strtotime('-7days'))

                                    ],

                                    'options'       => [

                                        'class'         => 'form-control',

                                        'maxlength'     => '10',

                                        'placeholder'   => 'Data inicial',

                                        ]

                                ]

                            )->label(false) ?>

                            </div>

                            <div class="col-md-4"> 

                            <?= $form->field($model, 'endDate')->widget(DatePicker::classname(), 

                                [

                                    'language'      => 'pt-BR',

                                    'dateFormat'    => 'dd/MM/yyyy',

                                    'clientOptions' => [

                                        'yearRange'     => '2005:+0', 

                                        'defaultDate'   => date('d/m/Y')

                                    ],

                                    'options'       => [

                                        'class'         => 'form-control',

                                        'maxlength'     => '10',

                                        'placeholder'   => 'Data final',

                                        ]

                                ]

                            )->label(false) ?>

                            </div>

                            <div class="col-md-4"> 

                            <?= Html::submitButton('Filtrar', ['class' => 'btn btn-primary']) ?>

                            <?php yii\widgets\ActiveForm::end(); ?>

                            </div>

And my model:


<?php


namespace frontend\models;


use yii\base\Model;

use Yii;


class Analysis extends Model

{

    public $startDate;

    public $endDate;


    public function rules()

    {

        return [

            ['startDate', 'required'],

            ['startDate', 'date', 'format' => 'dd/MM/yyyy'],

            ['startDate', 'checkDateToday'],

            ['startDate', 'checkGAMinDate'],


            ['endDate', 'required'],

            ['endDate', 'date', 'format' => 'dd/MM/yyyy'],

            ['endDate', 'checkDateToday'],

            ['endDate', 'checkGAMinDate'],

            ['endDate', 'checkDateGreaterThan']

        ];

    }


    public function checkDateToday($attribute, $params)

    {

        if($this->$attribute <= date('d/m/Y')){

            return true;

        } else {

        var_dump($this->$attribute);

            $this->addError($attribute, $attribute . ' não pode ser maior que hoje: ' . date('d/m/Y'));

        }

    }    


    public function checkGAMinDate($attribute, $params)

    {

        if($this->$attribute > date('01/01/2005')){

            return true;

        } else {

            $this->addError($attribute, $attribute . ' não pode ser menor que 01/01/2005');

        }

    }


    public function checkDateGreaterThan($attribute, $params)

    {

        if($this->endDate < $this->startDate){

            return true;

        } else {

            $this->addError($attribute, 'Data final não pode ser maior que data incial.');

        }

    }


    public function attributeLabels()

    {

        return [

            'startDate' => Yii::t('app', 'Data inicial'),

            'endDate'   => Yii::t('app', 'Data final'),

        ];

    }

}

When i put a date like “25/12/2015” (‘d/m/Y’), the model return after validate: “12/25/2015”. Whats going wrong?

checkDateToday and checkGAMinDate contain compare date in wrong format; they should be "yyyy-mm-dd".