E
E
Eugene2018-05-24 15:49:15
Yii
Eugene, 2018-05-24 15:49:15

How to correctly access the model in order to correctly pull the data through the beetween?

In general, I use DateRangePicker. On change, I send two date boundaries to the server and make a request.

if (Yii::$app->request->isAjax && Yii::$app->request->isPost)
        {

            $order = Yii::$app->request->post('a');
            $orderdate = Orders::find()
                ->where(['between', 'date', $order[0], $order[1]])->all();           

            $cat = Category::find()->all();
            $price = Price::find()->all();

            return $this->asJson([$orderdate, $cat ,$price]);

        }

Noticed this bug. If you choose today or tomorrow in picker. T e specific range. Let's say 05/12/2018/05/12/2018 and if there were orders on the 12th, then emptiness comes. And if I choose intermediate days, then everything will return normally. I suspect that this is due to the fact that in the database I have the date format 2018-05-24 13:37:45 , and I send the date 2018-05-24 without time. So here's how to correctly add 00:00 to the first range, and 23:59 to the second so that it always includes the ends?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2018-05-24
@qonand

I suspect that this is due to the fact that in the database I have the date format 2018-05-24 13:37:45 , and I send the date 2018-05-24 without time.

you understand correctly
before queries and the base, add the time to the corresponding variables containing dates

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question