operator <=




$profil = Company::find()

    ->filterWhere(['>=', 'published_at',strtotime('16-11-2017')])

    ->andFilterWhere(['<=', 'published_at',strtotime('16-11-2017')])

    ->all();


result 

null


$profil = Company::find()

    ->filterWhere(['>=', 'published_at',strtotime('16-11-2017')])

    ->andFilterWhere(['<=', 'published_at',strtotime('17-11-2017')])

    ->all();


result 

'16-11-2017' '16-11-2017'




$profil = Company::find()

    ->filterWhere(['<=', 'published_at',strtotime('17-11-2017')])

    ->all();


result

'16-11-2017' '16-11-2017'


$profil = Company::find()

    ->filterWhere(['>=', 'published_at',strtotime('16-11-2017')])

    ->all();


result

'16-11-2017' '16-11-2017' '17-11-2017' '17-11-2017' '17-11-2017' '17-11-2017' '17-11-2017'



in my model




public function rules(){

        return [

            ['published_at', 'date', 'timestampAttribute' => 'published_at', 'format' => 'dd-MM-yyyy'],

            ['published_at', 'default', 'value' => time()],

        ];

    }


public function getPublishedDate(){

        return Yii::$app->formatter->asDate(($this->isNewRecord) ? time() : $this->published_at,'dd-MM-yyyy');

    }



in my db there are only two dates.

date "17-11-2017" wont showing while use operator "<=" with the same filter date.

what i miss?

$profil = Company::find()

-&gt;filterWhere(['=', 'published_at',strtotime('16-11-2017')])


-&gt;all();

result

null

$profil = Company::find()

-&gt;filterWhere(['published_at' =&gt; strtotime('16-11-2017')])


-&gt;all();

result

null

Is ‘published_at’ a TIMESTAMP?

Then a published time represented as ‘17-11-2017’ may acutually have a different value from ‘2017-11-17 00:00:00’.

‘2017-11-17 12:34:56’, for example, is not equal to strtotime(‘17-11-2017’) which is ‘2017-11-17 00:00:00’.

many thanks bro. i missed that… :lol: :lol: