Yii2 model-> created_date in the future and does not return on request

I installed Yii->application->configuration->timezonein UTCand had a model attributeBehaviorsfor automatically setting / updating the timestamp using the PHP method time().

The problem is that the timestamp, which is stored in db in the future, and when I do a search for records from today, they do not return if they were created between 10 and midnight, since the timestamp is actually tomorrow.

How to create a record and perform a search query?

Thanks.

+4
source share
1 answer

, PHP MySQL.

:

echo date_default_timezone_get() . "<br>";
echo Yii::$app->formatter->timeZone . "<br>";
echo Yii::$app->formatter->defaultTimeZone  . "<br>";
echo Yii::$app->db->createCommand('SELECT @@time_zone')->queryScalar()  . "<br>";
echo Yii::$app->db->createCommand('SELECT @@system_time_zone')->queryScalar()  . "<br>";

( MySQL, - )

- PHP MySQL ( PHP, Yii2)

+1

Source: https://habr.com/ru/post/1612871/


All Articles