[SOLVED]Another date comparison question
Posted: Tue Oct 31, 2006 8:22 pm
I'm trying to work out how to determine whether a particular date is between two other dates.
I have done an extensive search of these forums and the Internet but none of the solutions seem to work with my code!
The values in $days_booked are accessed from a date value in MYSQL.
Heres the basic code: (Assume that the current day is 17 November 2006; a day in between the two mentioned dates)
;
I've also tried this method aswell without success (whereby $temp_booked_from and $temp_booked_until is an array as a result of using explode( ) on $days_booked[0] and $days_booked[1])
I have done an extensive search of these forums and the Internet but none of the solutions seem to work with my code!
The values in $days_booked are accessed from a date value in MYSQL.
Heres the basic code: (Assume that the current day is 17 November 2006; a day in between the two mentioned dates)
Code: Select all
$days_booked[0]=2006-11-15;
$days_booked[1]=2006-11-20;
$current_year=date("o");
$current_month=date("n");
$current_day_tracker=17;
$days_booked_tracker=1;
if(strtotime($current_year."-".$current_month."-".$current_day_tracker) >= strtotime($days_booked[$days_booked_tracker-1])
&& strtotime($current_year."-".$current_month."-".$current_day_tracker) <= strtotime($days_booked[$days_booked_tracker]))
$is_booking_period=true;
else $is_booking_period=falseI've also tried this method aswell without success (whereby $temp_booked_from and $temp_booked_until is an array as a result of using explode( ) on $days_booked[0] and $days_booked[1])
Code: Select all
if(date("d-M-Y", mktime(0, 0, 0, $current_month, $current_day_tracker, $current_year)) >= date("d-M-Y", mktime(0, 0, 0, $temp_booked_from[1], $temp_booked_from[2], $temp_booked_from[0]))
&& date("d-M-Y", mktime(0, 0, 0, $current_month, $current_day_tracker, $current_year)) <= date("d-M-Y", mktime(0, 0, 0, $temp_booked_until[1], $temp_booked_until[2], $temp_booked_until[0])))