0

I have a report that calculates employee working hours by retrieving date, punch in and punch out and calculate duration, this data is saved into an array to be displayed based on the payroll period, here is the code that calculates payments based on a weekly period (looping within array)

foreach($punch_sets as $val){
    if ($currentmonth==""){
        echo "<tr><td>" . date("W",strtotime($val['in_date'])) . "</td>";
     }
    if ($currentmonth1 == date("F",strtotime($val['in_date'])) || $currentmonth1 ==""){


      if ($currentmonth == date("W",strtotime($val['in_date'])) || $currentmonth==""){
                 $total_time += $minSec + $hours*3600;
                 $currentmonth = date("W",strtotime($val['in_date']));
           }
       else
           {
               echo "<td>" . sec2hm($total_time) . "</td>";
               echo "<td>" . (sec2hm($total_time) * $ratepaid) . "</td></tr></tr>";

               $currentmonth ="";
               $total_time = $minSec + $hours*3600;
            }
  }

    else {
          $total_time = $minSec + $hours*3600;
        }
         $currentmonth1 = date("F",strtotime($val['in_date']));
}

The question here how do I adjust this logic to get bi weekly calculation instead of weekly.

4

1 回答 1

0

而不是使用:

date("W",strtotime($val['in_date']))

分组依据,分组依据:

floor(date("W",strtotime($val['in_date']))/2);

您可能希望更改$currentmonth$currentperiod以反映原始脚本从每月一次到每周一次到现在每两周一次的变化。

于 2013-05-15T17:48:05.187 回答