I need to verify that the input value of a variable is in the correct format prior to writing to mySQL. MySQL wants the date in the following format... YYYY-MM-DD (for example, 2002-02-23). If it is not in this format, mySQL will record it as whatever default value I have chosen.
So, is there some slick and easy way to pull this string apart, and check the individual components for validity? I started with trying a regular expression but realized it may be easier to actually work on the various substrings and check each one against the possible rages for Y, M and D.
Just wondering if this is such a common task that there is some adopted method that is in common use.
(I am reasonably competent with PHP, by quite new to MySQL and are at the stage where I tend to things the hard way.)