code: protected function calculateEventLength(array $data)
      {
          $start = $this->carbon->copy()->setTimestamp(strtotime($data['start']['date'] . ' ' . $data['start']['time']));
  
          if (array_key_exists('all_day', $data)) {
              $end = $this->carbon->copy()->setTimestamp(strtotime($data['start']['date'] . ' 23:59:59'));
          } else {
              $end = $this->carbon->copy()->setTimestamp(strtotime($data['start']['date'] . ' ' . $data['end']['time']));
          }
  
          return $start->diffInSeconds($end);
      }
docs: Calculate event length in seconds
  
  @param array $data
  
  @return int