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; } ?> Link to comment https://forums.phpfreaks.com/topic/241674-preg_match/ 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; } ?> Link to comment https://forums.phpfreaks.com/topic/241674-preg_match/#findComment-1241243 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.