find date difference of from two datepicker

I have tow date fields using date picker ,

code for both is as below ( name is differtne ) ,


	&#036;this-&gt;widget('zii.widgets.jui.CJuiDatePicker', array(














– what i have to do is to find date diffrerence from both datepicker ( in days like 1,2,3, … )

Maybe …

  1. Convert each date string to a timestamp using CDateTimeParser::parse().

  2. Get the difference between 2 timestamps.

  3. Devide the diff by (24 * 60 * 60).

I’m not sure if it will work 100% or not. Just give it a try. :)

hi i am trying to show in a custom column grid that shows me the remains of two of the fields grid, and what would they be fecha_det_a1 fecha_ocu_a1

this function should develop in my admin because that’s where I want it to display. Already declared the variable in the model (), now this is the function:


function dateDiff($start, $end)


$start_ts = strtotime($start);

$end_ts = strtotime($end);

$diff = $end_ts - $start_ts;

return round($diff / 86400);




When I invoke the function within the grid, I do soÑ

<?php $this->widget(‘zii.widgets.grid.CGridView’, array(


‘itemsCssClass’=>“table table-striped”,


















)); ?>

but when I go to access the admin view returns me the following error:

call_user_func_array() expects parameter 1 to be a valid callback, no array or string given

could you help me? thanks

Is dateDiff() declaired in the model? (nitpik: Add Public to it)

$fdfo=dateDiff($model->fecha_det_a1,$model->fecha_ocu_a1); is in the view? If yes then I think you need to do:


You could also add a public $fechaDateDiff to the model, and set it in the afterFind() function. Then you could diplay it with $model->fechaDateDiff

Just some thoughts 8)