Prado\Util\TSimpleDateFormatter::isValidDate PHP Метод

isValidDate() публичный Метод

public isValidDate ( $value ) : boolean
Результат boolean true if the given value matches with the date pattern.
    public function isValidDate($value)
    {
        if ($value === null) {
            return false;
        } else {
            return $this->parse($value, false) !== null;
        }
    }

Usage Example

Пример #1
0
 /**
  * Determine if the given value is of a particular type using RegExp.
  * @param string value to check
  * @return boolean true if value fits the type expression.
  */
 protected function evaluateDataTypeCheck($value)
 {
     if ($value == '') {
         return true;
     }
     switch ($this->getDataType()) {
         case TValidationDataType::Integer:
             return preg_match('/^[-+]?[0-9]+$/', trim($value));
         case TValidationDataType::Float:
             return preg_match('/^[-+]?([0-9]*\\.)?[0-9]+([eE][-+]?[0-9]+)?$/', trim($value));
         case TValidationDataType::Date:
             $dateFormat = $this->getDateFormat();
             if (strlen($dateFormat)) {
                 $formatter = new TSimpleDateFormatter($dateFormat);
                 return $formatter->isValidDate($value);
             } else {
                 return strtotime($value) > 0;
             }
     }
     return true;
 }