ok so what you need to do is use the PHP date time fucntions to find the elasped time per activity.
Im assuming you work on the basis that timings alternate. ie odd timings (in the sequence) are clocking on, even timings are clocking off
when ordered by userid and in_outtime Nos 1,3,5,7 are alwasy clocking on, 2,4,6,8 are always clocking out.
it may depend on how you have stored the those values. Im surprised to find separate columns called date and in_outtime. in an ideal world anything that is date/time related should be on a single datetime datatype. doing so makes any mathmatical operation on the data much much easier. there;s a whole suite of functions in PHP (and also virtually all languages and database engines) for handling such data. in PHP they can be found here:-
PHP: Date/Time Functions - Manual
so effectively you need to subtract the preceeding value from the current value, assuming the current value is an even number in the series. the psuedo code would be something like this:-
is_clockon = true 'identifies if this record is a clock on or clock off value
'on startup it will always be a clockon
clockontime 'will store the vlaue of the clock on
elapsedtime = 0 'will store the elapsed time in minutes
do loop
if is_clockon=true then
clockontime = curent value
else
ThisTimeAtOffice = datediff(currentvalue,clockontime)
elapsedtime = elaspedtime + format(timeatoffice,"%i)
endif
//next row
if you also needed the clock off time, then tke not of the first value and subtract it (using datediff) from the last value.