I am using Kartik GridView and my date column setup is the following
[
'attribute'=>'created_date',
'value' => function ($model, $index, $widget) {
return Yii::$app->formatter->asDate($model->created_date);
},
'format' => ['date', 'php:d.m.Y'],
'filterType' => GridView::FILTER_DATE,
'filterWidgetOptions' => [
'pluginOptions' => [
'format' => 'yyyy-mm-dd',
'autoclose' => true,
'todayHighlight' => true,
]
],
'width' => '160px',
'hAlign' => 'center',
],
Search model
[['created_date'], 'safe'],
$query->andFilterWhere([
'links_id' => $this->links_id,
'modified_date' => $this->modified_date,
'created_date' => $this->created_date,
]);
created_date is the column in the database that is generated automatically when record is created, which has the following format
2015-12-16 13:42:09.425618.
Although date picker works I get SQL Error:
The SQL being executed was: SELECT COUNT(*) FROM "links" LEFT JOIN "countries" ON "links"."country" = "countries"."country" WHERE "created_date"='2015-12-15'
So, how to properly filter unix timestamp with Yii2 kartik date picker?