$date="2012-09-12";
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$date)) {
return true;
} else {
return false;
}
/^(?:[0-9]{4}-[0-9]{2}-[0-9]{2})?(?:[ T][0-9]{2}:[0-9]{2}:[0-9]{2})?(?:[.,][0-9]{3})?/gm
2019-04-29 this line has only date
2019-04-29 14:10:32 this line has date and time without the "T" separator
2019-04-29T14:10:32 this line has date and time with the "T" separator
2019-04-29T14:10:36 this line has no milliseconds
2019-04-29 14:10:32,999 this line has milliseconds using comma, but without the "T" separator
2019-04-29T14:10:32,999 this line has milliseconds using comma
2019-04-29T14:10:36.000 this line has milliseconds using decimal point
php date