DarkPrince2005 Posted July 11, 2011 Share Posted July 11, 2011 Can anyone assist in searching through a text field for dates? <?php $text = "01-01-2011"; if (preg_match("(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9]{2}", $text)) { return TRUE; echo 'true'; } else { return FALSE; } ?> Quote Link to comment Share on other sites More sharing options...
teynon Posted July 11, 2011 Share Posted July 11, 2011 <?php $text = "01-01-2011"; if (preg_match("@[\d][\d]-[\d][\d]-[\d][\d][\d][\d]@", $text)) { echo 'true'; return TRUE; } else { echo "false"; return FALSE; } ?> 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.