【发布时间】:2018-07-16 16:48:04
【问题描述】:
我想过滤日期列,例如 3 个月前、6 个月前、1 年前。 我在 gridview 的搜索字段中创建了一个下拉列表,如下所示。
[
'attribute' => 'modified',
'value' => 'name',
'filter' => array("ID1" => "Before Three months",
"ID2" => "Before six months",
"ID" => "Before Twelve months",),
],
在模型搜索中我想搜索...
if (($this->modified) == "ID1"){
$query->andFilterWhere(['between', $this->modified, 'today', '3monthsago']);
}
但我不明白应该用什么来代替今天 3monthsago ? 如何在查询中计算和传递这个变量??
【问题讨论】: