如何检查两个时间戳是否在一个范围内

I need to create some code which will check if two timestamps (generated by strtotime function) are within a range of a further two timestamps.

If they are within the range it should return 0.

If they are not in the range it should find how many seconds overlap and return the result as a number.

<?php
  function check_range($time1, $time2, $max_difference)
  {
      $overlap = abs($time1-$time2);
      if($overlap < $max_difference)
      {
         return 0;
      }
      else
      {
        return $overlap;
      }

  }