Php regex date validation -
i'm trying validate date input use of regex. if(!preg_match("/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/", $_post['variant']['sales_start'])) { echo "invalid"; } the string i'm trying input 2011-02-03, it's failing, , can't seem figure out why. can please tell me i'm doing wrong? thanks in advance you're separating date dashes , regex looking slashes? try if ( !preg_match( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $_post['variant']['sales_start'] ) ) { echo "invalid"; }