Quote:
Originally Posted by wolfey
If its not asking too much, can you help me with code I can use?
to check date submitted is at least 2 weeks in advance from todays date
Thank you much.
Chris.
|
OK got this code and an error displays if less than 2 weeks date selected,
Question: How do I display text on the output instead of preventing the form from being submitted when less than 2 weeks?
PHP Code:
$nowDate=new DateTime();
$nowMDY=$nowDate->format('j F Y');
$twoWeekdOutDate=new DateTime($nowMDY);
$twoWeekdOutDate->add(new DateInterval('P14D'));
$twoWeekdOutDate->format('j F Y');
try{
$inputDate=new DateTime($qo[88]);
}catch(Exception $e){
standard_error("Invalid date: " . $qo[88]); //should never come here
}
if($inputDate>=$twoWeekdOutDate){
//good
}else{
standard_error("Please enter a date 2 weeks or more in advance - " . $qo[88]);
}