1 week ago

Cannot get sum of the total working hours.

Posted 1 week ago by sanjayacloud

Hi Guys,

I am trying to get sum of total working hours for the user.

My code like below

                                     $total_hours = array();
                                    @foreach($reports as $report)
                                                    $dteStart = new DateTime($report->check_in_time);
                                                    $dteEnd   = new DateTime($report->check_out_time);
                                                    $dteDiff  = $dteStart->diff($dteEnd);
                                                {{ round($dteDiff->format("%H:%I"), 2) }}
                                            <td> {{ $dteDiff->format("%H:%I") }}</td>
                                            $dt = $dteDiff->format("%H:%I");
                                            $total_hours[] = $dteDiff->format("%H:%I");

And show sum of the working hours.

<p>{{ array_sum($total_hours)}}</p>

This total coming from

23:00 + 01:05 

Total should be 24:05, But my showing value is rounded value "24". can I know how to show the actual value of "24:05"?

Please sign in or create an account to participate in this conversation.