fork download
  1. <?php
  2.  
  3. function convert($t)
  4. {
  5. list ($h, $m, $s) = explode(':', $t);
  6. return $s + 60 * ($m + 60 * $h);
  7. }
  8.  
  9. $one_day = 24 * 60 * 60;
  10. $starttime1 = convert('23:00:00');
  11. $endtime1 = convert('04:00:00');
  12.  
  13. if ($endtime1 < $starttime1) {
  14. $endtime1 += $one_day;
  15. }
  16.  
  17. $starttime2 = convert('19:00:00');
  18. $endtime2 = convert('23:30:00');
  19.  
  20. if ($endtime2 < $starttime2) {
  21. $endtime2 += $one_day;
  22. }
  23.  
  24. if (($endtime2 >= $starttime1 && $endtime2 <= $endtime1) ||
  25. ($starttime2 >= $starttime1 && $starttime2 <= $endtime1))
  26. {
  27. echo ("intersect");
  28. } else {
  29. echo ("doesn't intersect");
  30. }
  31.  
  32. ?>
  33. // your code goes here
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
intersect// your code goes here