I\'m receiving a date string from an API, and it is formatted as yyyy-mm-dd
.
I am currently using a regex to validate the string format, which works ok,
You can also Parse the date for month date and year and then you can use the PHP function checkdate()
which you can read about here: http://php.net/manual/en/function.checkdate.php
You can also try this one:
$date="2013-13-01";
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$date))
{
echo 'Date is valid';
}else{
echo 'Date is invalid';
}