hi there...
how can i get time difference ?
for ex :
i have presence table,
field : id,name,time_come,time_home,duration
duration field is difference between time_home and time_come (time_home - time_come)
how can i get it? what function i must do in GC? or any suggest / any tutorial link for beginner?
thanks in adv
time difference
- Single Page
Posted 08 October 2013 - 07:31 AM
Posted 09 October 2013 - 09:59 AM
Hi,
You use callback_column to calculate the value for the duration column then in your callback function use any of the php methods for calculating an interval (depending on which version of php you are using). So something like this (check the php date/time object docs to be sure)
$c->columns('id','name','time_come','time_home','duration'); $c->callback_column('duration',array($this,'_callback_interval')); . . . . . . public function _callback_interval($value, $row) { $datetime1 = new DateTime($row->time_come); $datetime2 = new DateTime($row->time_home); $interval = $datetime1->diff($datetime2); return $interval->format('H:i:s'); }