Testing for intersection of two date/time ranges
Posted: Thu Nov 06, 2003 6:16 am
I would like to test for appointment conflicts in an app I am working on.
How does this method sound.
I retrieve a start and finish date-time from mysql for each appointment.
I use mktime and obtain a time stamp for each start finish time.
I then create and arrays using
array1 = range(starttime 1, endtime 1)
array2 = range(starttime 2, endtime 2)
I then attempt to use $intersect = array_intersect (array1, array2)
If $intersect is empty no app conflict etc, however this method is probably extremely memory intensive and on my machine times out.
Is the problem that array_intersect requires strings and that range provides arrays of integers.
Maybe someone has a better method of comparison/intersection of two or more date ranges.
Any help appreciated.
How does this method sound.
I retrieve a start and finish date-time from mysql for each appointment.
I use mktime and obtain a time stamp for each start finish time.
I then create and arrays using
array1 = range(starttime 1, endtime 1)
array2 = range(starttime 2, endtime 2)
I then attempt to use $intersect = array_intersect (array1, array2)
If $intersect is empty no app conflict etc, however this method is probably extremely memory intensive and on my machine times out.
Is the problem that array_intersect requires strings and that range provides arrays of integers.
Maybe someone has a better method of comparison/intersection of two or more date ranges.
Any help appreciated.