Some folks helped me on
How to check the data format in PHP
post but I need to check two date formats MM-DD-YYYY and DD-MM-YY instead of one. Do I need to setup two regular expression???? Thanks for the help!!!
$date1=05/25/2010;
$date2=25/05/10; //I wish both of them would pass
$date_regex = '!^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$!';
if (preg_match($date_regex, $date1)) {
do something
}
if (preg_match($date_regex, $date2)) { // need second Reg. expression??
do something
}
Your regex
matches MM-DD-YYYY format.
The other you want to match is simple
You could just check if either is true.
Or you could combine them using
Not the most elegant regex but it shold work just fine.