Adding calculated date value in gridview

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
B. Palmer
Forum Newbie
Posts: 4
Joined: Mon Apr 09, 2012 3:54 pm

Adding calculated date value in gridview

Post by B. Palmer »

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 PHP so I need lots of help. Thanks!

Here's the ExCGridView widget call:
<?php $this->widget('ExCGridView', array(
'id'=>'lessonInfo-grid',
'dataProvider'=>$model->search(),
'rowCssClassExpression'=>'$data->actionNeeded ? "bold ". ($row%2 ? "even" : "odd") : ($row%2 ? "even" : "odd")',
'columns'=>array(
'id',
'startedDate',
'student.studentEnrollment.classroom',
'student.studentEnrollment.classroom.teacher',
'student',
'lesson'
),
),
)); ?>
Post Reply