I have a basic table which captures time and attendance.
I'm trying to out put the total hours on site, from my eloquent query:
$attendance = DB::table('staff_attendances')
->whereBetween('in_date', array($date1, $date2))->where('staff_id', $ID)->select('first_name', 'last_name', 'in_date', 'out_date', 'in_time', 'out_time')->get();
I get the following back in json.
[{"first_name":"TestFirst","last_name":"TestLast","in_date":"2016-01-30","out_date":"2016-01-30","in_time":"11:40:34","out_time":"12:41:10"},
{"first_name":"TestFirst","last_name":"TestLast","in_date":"2016-01-30","out_date":"2016-01-30","in_time":"13:02:27","out_time":"14:02:32"}]
Which method would be best to out put total hours on site?
I've tried using carbon with the following:
$startTime = Carbon::parse($attendance->in_time);
$finishTime = Carbon::parse($attendance->out_time);
$totalDuration = $finishTime->diffInHours($startTime);
But I get "Trying to get property of non-object"
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1JOQN8b
via IFTTT
Aucun commentaire:
Enregistrer un commentaire