I've not posted on here before, but have used the forum as a resource in the past. Usually I like to figure things out for myself but this one has me confused.
I have a fair amount of experience with php but up until now have not needed to use regex (I did use it with Perl around 2000/1 but have forgotten everything).
Anyway the issue is, I have a date format '2011-12-31' which I believe should match the pattern below - problem is it doesn't!
Does anyone have any ideas?
Code: Select all
if (preg_match('((19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01]))',$date_from)) {
$valid_input = 1;
echo "<p>Date From is valid</p>";
} else {
echo '<p class="red_text">Date From is invalid.</p>';
$valid_input = 0;
}