I have a mysql table with one of the fields as datetime in the datetime format. I want to change the following query to one that will check the datetime of each record and only return those records that are greater than the current time and date.
$dataProvider = new ActiveDataProvider([
'query' => NflLines::find(),
]);
Assuming your column with datetime is named datetime
, you can do it like this:
use yii\data\ActiveDataProvider;
use yii\db\Expression;
...
$query = NflLines::find()->where(['>', 'datetime', new Expression('NOW()')]);
$dataProvider = new ActiveDataProvider(['query' => $query]);
Read more about ways of specifying where
condition here and wrapping with expression here in official docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With