$query->andFilterWhere(['>=', 'createDate', $this->createDateFrom ? $dateCreateFrom->getTimestamp() : null,])
->andFilterWhere(['<=', 'createDate', $this->createDateTo ? $dateCreateTo->getTimestamp() : null,]);
$dateCreateFrom = new DateTime($this->createDateFrom, new DateTimeZone('UTC'));
$dateCreateTo = new DateTime($this->createDateTo, new DateTimeZone('UTC'));
$query->andFilterWhere(['>=', 'createDate', $this->createDateFrom ? $dateCreateFrom->getTimestamp() : null,])
->andFilterWhere(['<=', 'createDate', $this->createDateTo? $dateCreateTo->getTimestamp() : null,]);
$dateCreate = new DateTime($this->createDate, new DateTimeZone('UTC'));
$query->andFilterWhere([
'=', 'createDate',
$this->createDate ? $dateCreate->getTimestamp() : null,
'id' => $this->id,
'type' => $this->type,
'userId' => $this->userId,
'status' => $this->status,
'updateDate' => $this->updateDate,
]);
public static function setCookies(){
$cookies = Yii::$app->request->cookies->getValue('name_cookie');
if(!$cookies){
$set_cookies_date = (new DateTime())->modify('+1828 day')->format('d.m.Y H:i:s');
$ip = Yii::$app->request->userIP;
$hash = md5(microtime() . rand(0, 1000) . $ip);
$set_cookies = Yii::$app->response->cookies;
$set_cookies->add(new \yii\web\Cookie([
'name' => 'name_cookie',
'value' => $hash,
'domain' => 'site.local',
'expire' => strtotime($set_cookies_date),
]));
}
}
<?php
setcookie("TestCookie", 'fddfdf');
?>
Хотя в гет запросе они есть NewsSearch[createDateFrom]=2021-04-26&NewsSearch[createDateTo]=2021-04-28