Php regex date validation

后端 未结 4 999
天命终不由人
天命终不由人 2020-12-12 01:03

I\'m trying to validate a date input by the use of regex.

if(!preg_match(\"/^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$/\", $_POST[\'variant\'][\'sales_start\'])) { 
           


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 01:46

    Also, use PHP function checkdate() in order to validate your date according to Gregorian calendar - http://php.net/manual/en/function.checkdate.php

提交回复
热议问题