aolong Posted May 28, 2009 Share Posted May 28, 2009 Can someone explain why the following is not working... $splitDate = explode("-", $expires); //split the expires field $yy = $splitDate[0]; // first element is year $mm = $splitDate[1]; // second argument is month $dd = $splitDate[2]; // third argument is day echo $yy . $mm . $dd; // debug, just to check the array values are right... if(!checkdate($yy, $mm, $dd)){ $errors[] = "$expires is an invalid date. <br /> \r\n"; } $expires is always in form yyyy-mm-dd. When I echo $yy, $mm, $dd, they are returned correctly as (for example) 2008, 01, 01 - never-the-less it is returning an error... Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted May 28, 2009 Share Posted May 28, 2009 Because, as the manual page says, the parameters should be in the order of month, day then year. You should make the manual first port of call of things like this. Quote Link to comment Share on other sites More sharing options...
anupamsaha Posted May 28, 2009 Share Posted May 28, 2009 Syntax of "checkdate()" is bool checkdate ( int $month , int $day , int $year ) So, change the if (checkdate....) statement in your code. Quote Link to comment Share on other sites More sharing options...
aolong Posted May 28, 2009 Author Share Posted May 28, 2009 Actually, I read the manual page, but thank you for the clarification! It works now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.