src/Validate.php
public static function sqlDate($date, $field_name = 'date')
    {
        if (preg_match('/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/', $date, $matches)) {
            if (checkdate($matches[2], $matches[3], $matches[1])) {
                return $date;
            }
        }
        throw new IncorrectParametersException([ $field_name]);
    }
public static function sqlDate($date, $field_name = 'date')
    {
        if (preg_match('/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/', $date, $matches)) {
            if (checkdate($matches[2], $matches[3], $matches[1])) {
                return $date;
            }
        }
        throw new IncorrectParametersException([ $field_name]);
    }
public static function sqlDate ( $ date , $ field_name = 'date' ) { if ( preg_match ( '/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/' , $ date , $ matches ) ) { if ( checkdate ( $ matches [ 2 ] , $ matches [ 3 ] , $ matches [ 1 ] ) ) { return $ date ; } } throw new IncorrectParametersException ( [ $ field_name ] ) ; }
Validate SQL date, datetime
@param string $date Input date
@param string $field_name [optional] Field's name, used in IncorrectParametersException.
Optional default is date
@return string
@throws IncorrectParameters If value type is not correct.
Validate SQL date datetime