caveat: i am new to php
I'm reading in 2 dates from a form in a mysql format (i.e. YYYY-MM-DD) and trying to error check them both for validity and that one is less than the other
if(!empty($day1) && !empty($day2)){
$sndate=array();
$sndate = explode('-',$day1);
$sndtnum = implode($sndate);
$sndtnum = (int) $sndtnum;
$unsndate=array();
$unsndate = explode('-',$day2);
$unsndtnum = implode($unsndate);
$unsndtnum = (int) $unsndtnum;
if (!checkdate($sndate[1],$sndate[2],sndate[0]) || !checkdate($unsndate[1],$unsndate[2],unsndate[0]) || $unsndtnum<$sndtnum)
{ $error=True; $errtext .="Date field is filled in wrong
";
}else {$error=False;}
}
This does not seem to work. I'm pretty sure it's because of the checkdate, but i'm not positive that there isn't also an issue with the implode/cast.
Any ideas on how to fix this?