H
H
hollanditkzn2017-10-06 10:59:47
Yii
hollanditkzn, 2017-10-06 10:59:47

How to display records that have expired 2 weeks?

I have such a problem, in that I can’t figure out how to display records that have already passed 2 weeks in modelSearch.
I tried something like this But

$query = Custom::find()->indexBy('id')->with('idUser');
$query->andWhere(['<', 'date', date('Y-m-d H:i:s', strtotime($this->date)+3600*24*14)])
                ->andWhere(['action' => Custom::CUSTOM_BROUGHT]);

Only $this will not help, what to do here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-10-06
@hollanditkzn

as far as I understand your problem is that you do not know how to form a date that was two weeks ago, if so then it is worth replacing
on the
date('Y-d-m H:i:s', strtotime('- 2 week'));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question