I am using the following sample code to calculate sum of two different time values. Now I want to get the sum of N number of time values.
// numbers for test
Laravel Framework (PHP language)
$chores = ChoresTime::where('family_id', $family->id)->get();
$total = [];
foreach ($chores as $key => $value) {
$total[] = $value->time;
}
$total = CalculateTime($chores);
return response()->json([
'status' => 1,
'message' => 'Total Time',
'data' => [],
'total' => $total
], ok());
Answer:
{
"status": 1,
"message": "Family Total Chores Time",
"data": [],
"total": "14:22"
}