Is it a propoer approach to use regex to check if the user input comply with the date time format "yyyy-mm-dd hh:mm:ss"? I tired this one but it far from enough as it cannot check say, mm is larger than 12...dd should not be 31 if mm is 11...etc
if (ereg ("([1-2][0-9]{3}-[0-9]{1,2}-[0-9]{1,2} [0-9]{2}:[0-9]{2}:[0-9]{2})"
, $datetime, $regs))
{
} else {
echo "Invalid date format";
}
could anyone help me on that ? Can it be done with one regex ?