Skip to content

Instantly share code, notes, and snippets.

@guiman
Created May 29, 2012 00:01
Show Gist options
  • Save guiman/2821760 to your computer and use it in GitHub Desktop.
Save guiman/2821760 to your computer and use it in GitHub Desktop.
Time Range Overlap verification
<?php
/*
@param String $time1 , Time representation
@param String $time2 , Time representation
@return boolean , wheter time range 1 and time range 2 overlaps or not
*/
public function overlaps($from1,$to1,$from2,$to2)
{
$start1 = strtotime($from1);
$end1 = strtotime($to1);
$start2 = strtotime($from2);
$end2 = strtotime($to2);
return (($start1 < $end2) && ($start2 < $end1));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment