'class' => 'kartik\grid\FormulaColumn',
'header' => 'Days Work',
'value' => function ($model, $key, $index, $widget) {
$time = new \DateTime('now');
$today = $time->format('Y-m-d');
$p = compact('model', 'key', 'index');
$datetime2 = $model->activedate;
$interval = $today->diff($datetime2)->days;
return $interval;
},
'headerOptions' => ['class' => 'kartik-sheet-style'],
'hAlign' => 'right',
'width' => '7%',
],
我使用上面的代码来计算今天的日期和活动日期之间的日期。代码显示错误
Call to a member function diff() on string
.
请告诉我哪里错了。
非常感谢。