Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在非工作时间和工作日暂停SLA时钟_Php - Fatal编程技术网

Php 在非工作时间和工作日暂停SLA时钟

Php 在非工作时间和工作日暂停SLA时钟,php,Php,我有一个需要计算SLA的要求。我有一个优先级(p2),其中SLA响应时间为4小时,我能够计算SLA时间戳,该时间戳不包括非工作时间(17:00 PM),也不包括周末,如周六和周日。 但我陷入了这样的困境:sla时钟应该在非工作时间和非工作日暂停,并且应该在下一个工作日/小时恢复 我计算SLA的功能如下: function calculateP2SLA($totalMinutes,$reportDate) { $responseDate = new DateTime($reportDate);

我有一个需要计算SLA的要求。我有一个优先级(p2),其中SLA响应时间为4小时,我能够计算SLA时间戳,该时间戳不包括非工作时间(<8:00 AM和>17:00 PM),也不包括周末,如周六和周日。 但我陷入了这样的困境:sla时钟应该在非工作时间和非工作日暂停,并且应该在下一个工作日/小时恢复

我计算SLA的功能如下:

function calculateP2SLA($totalMinutes,$reportDate) {
  $responseDate = new DateTime($reportDate);


  // check conditions and add 1 minute to provided date totalMinutes times
  for($i=0; $i<$totalMinutes;$i++) {
    // if time is before 8:00 (working hours) skip to 8:00
    if ($responseDate->format('G') < 8) {
      $responseDate->setTime(8, 0);
    }

    // if time is after 17:00 (working hours) skip to next day at 8:00
    if ($responseDate->format('G') >= 17) {
      $responseDate->add(new DateInterval('PT15H'));
      $responseDate->setTime(8, 0);
    }

    // for weekend weekend skip to monday at 8:00
    if (in_array($responseDate->format('D'), ['Sat', 'Sun'])) {
      $responseDate = $responseDate->modify('next monday 8:00');
    }

    $responseDate->add(new DateInterval('PT1M'));
  }

  return $responseDate;
  $resp_sla = $responseDate;
}
例如,如果我在今天16:30补票,P2 sla为4小时,则时钟应滴答到17:00,并在下一个工作日的剩余3:30小时内恢复 任何关于这方面的帮助/建议都将非常值得赞赏

if (($row[status] == 'Created' || $row[status] == 'Open') && ($resp_sla > $currenttime))

{      
    
    echo "<td bgcolor=#00EE0A> $total_min_resp </td>";
}

 else {
    
    echo "<td bgcolor=red> $total_min_resp </td>";
}