Adding calculated column to Gridview

I’m trying to add a column to my gridview. I want the new column to contain the number of days since the value of a field in the table (startedDate).

So far, I’m calculating the number of days as follows:

$today = getdate();

$dayCount = $today->diff(‘startedDate’);

Is this the best way to calculate this value? How do I include the dayCount value in my grid? I’m new to Yii/PHP so I need lots of help. Thanks!

Here’s the ExCGridView widget call:

<?php $this->widget(‘ExCGridView’, array(



‘rowCssClassExpression’=>’$data->actionNeeded ? "bold ". ($row%2 ? “even” : “odd”) : ($row%2 ? “even” : “odd”)’,










)); ?>

I think you need to take a look at customized/complex data columns.

Just what I needed. Thanks.

You could also add a virtual attribute to the model and do the calculation in afterFind method

So that the attribute would be available anywhere in your app