D
D
Daniil Sidorov2018-02-02 14:26:22
Yii
Daniil Sidorov, 2018-02-02 14:26:22

How to select today's entries in Yii2?

Hello, there is a table Bet , I'm trying to make a selection of records for today by the date field . It is of type timestamp , meaning it contains both the date and the time. It was possible to cut off the time thanks to the CAST function , but for some reason the request still does not display anything.

$bets = BetList::find()
            ->select('CAST(date AS DATE) AS date')
            ->where('order_id = :order_id', [':order_id' => $order->id])
            ->andWhere('date = :today', [':today' => date("Y-m-d")])
            ->one();

Moreover, if you print $bets->date and date("Ymd") separately , they will be absolutely identical.
What could be the problem? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2018-02-02
@webinar

https://htmlweb.ru/php/mysql_date_time.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question