rodfarrell
Member
I'm struggling with this validation and hoping someone can help me improve my php. The form is a booking form and the field is a date element. The rule is, a booking date can be for the next day if made prior to 9am today, otherwise the minimum date is the day after tomorrow. There is obviously an issue in my code though as every date entered is accepted. My code is as follows:
PHP:
$app = JFactory::getApplication();
$data = JFactory::getDate($data)->toUnix();
//date entered
$day=date('D',strtotime($data));
//today
$date = new DateTime($string);
if (date('H',strtotime($date)) < 9) {
$minDate = date('D',strtotime($date).' + 1 day' );
}
else {$minDate = date('D', strtotime($date).' + 2 days' );
}
if( $minDate <= $day){return true;}
else{return false;}