May be, it will help? $first_date and $second_date are in MySQL format(YYYY-mm-dd)
$arr_Y_m_d_first=explode('-', $first_date);
$arr_Y_m_d_second=explode('-', $second_date);
$seconds_first=mktime(0,0,0,$arr_Y_m_d_first[1],$arr_Y_m_d_first[2],$arr_Y_m_d_first[0]);
$seconds_second=mktime(0,0,0, $arr_Y_m_d_second[1],$arr_Y_m_d_last[2], $arr_Y_m_d_second[0]);
Now you can compare two dates when they are the seconds:
if ($seconds_first<$seconds_second){...}