crunchie Posted February 24, 2010 Share Posted February 24, 2010 Can anyone help me? I'm trying to write a regex for the date mmm-dd-yyyy and have it validate the year so it cannot be later than the current year. All I have so far is this $birth_date = "$_Get['birthdate']"; if(preg_match("/([^abc.])-(0[1-9]|[1-2][0-9]|30)-[0-9]{4}$/",$birth_date)){ echo "Your birthday is on: $birth_date<br>"; }else{ echo "Not a vaild date.<br>"; } I'm not sure how to proceed with the validation of the year. Any suggestions will be greatly appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
Deoctor Posted February 24, 2010 Share Posted February 24, 2010 isnt this topic belong to PHP regex.. Quote Link to comment Share on other sites More sharing options...
crunchie Posted February 24, 2010 Author Share Posted February 24, 2010 It is, but I noticed that after I posted it and I'm not sure how to move it. Quote Link to comment Share on other sites More sharing options...
crunchie Posted February 25, 2010 Author Share Posted February 25, 2010 Still looking for any type of help...If anyone has any ideas I'd be happy to entertain them Quote Link to comment Share on other sites More sharing options...
cags Posted February 25, 2010 Share Posted February 25, 2010 This is not something that Regex is suited for. It is for matching pattern sequences not making numerical comparisons. Capture the year as part of the pattern and compared it against date('Y') afterwards. Though there are probably better ways to validate a date than using Regex. 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.