I have a preg_match and it is supposed to flag if my date isn't in MM-YYYY format. Here is my code if (!empty($_POST['StartDate'][$row]) && !preg_match('/^(0[1-9]|1[0-2]) [-] (19|20)\d{2}$/',$_POST['Startdate'][$row])) {echo '<b>One of your Start Date columns is not in the proper format. Make Sure it is MM-YYYY<br/>';$dataOK=FALSE;} Code (markup): what did i do wrong? Please Help
(!empty($_POST['StartDate'][$row]) && !preg_match('/^(0[1-9]|1[0-2])\s*\-\s*(19|20)\d{2}$/',$_POST['Startdate'][$row]))
Alternatively you could do (make sure date is not empty) $rowtime = strtotime($_POST['StartDate'][$row]); $newstr = date("m-d-Y", $rowtime);