Return to Snippet

Revision: 26939
at May 17, 2010 10:37 by leonelsantos


Initial Code
/*
		
	check if time overlaps
	parameters should be same date format
		
*/
function intersectCheck($from, $from_compare, $to, $to_compare){
	$from = strtotime($from);
	$from_compare = strtotime($from_compare);
	$to = strtotime($to);
	$to_compare = strtotime($to_compare);
	$intersect = min($to, $to_compare) - max($from, $from_compare);
		if ( $intersect < 0 ) $intersect = 0;
		$overlap = $intersect / 3600;
		if ( $overlap <= 0 ):
			// There are no time conflicts
			return TRUE;
			else:
			// There is a time conflict
			// echo '<p>There is a time conflict where the times overlap by ' , $overlap , ' hours.</p>';
			return FALSE;
		endif;
}

Initial URL
http://www.kirupa.com/forum/showthread.php?t=340013

Initial Description

                                

Initial Title
Time Conflict Check

Initial Tags
php, date

Initial Language
PHP