validators\DateValidator $format

$format public property

The date format that the value being validated should follow. This can be a date time pattern as described in the ICU manual.

Alternatively this can be a string prefixed with php: representing a format that can be recognized by the PHP Datetime class. Please refer to http://php.net/manual/en/datetime.createfromformat.php on supported formats.

If this property is not set, the default value will be obtained from Yii::$app->formatter->dateFormat, see yii\i18n\Formatter::$dateFormat for details. Since version 2.0.8 the default value will be determined from different formats of the formatter class, dependent on the value of $type:

Here are some example values:

'MM/dd/yyyy' // date in ICU format
'php:m/d/Y' // the same date in PHP format
'MM/dd/yyyy HH:mm' // not only dates but also times can be validated

Note: the underlying date parsers being used vary dependent on the format. If you use the ICU format and the PHP intl extension is installed, the IntlDateFormatter is used to parse the input value. In all other cases the PHP DateTime class is used. The IntlDateFormatter has the advantage that it can parse international dates like 12. Mai 2015 or 12 мая 2014, while the PHP parser is limited to English only. The PHP parser however is more strict about the input format as it will not accept 12.05.05 for the format php:d.m.Y, but the IntlDateFormatter will accept it for the format dd.MM.yyyy. If you need to use the IntlDateFormatter you can avoid this problem by specifying a minimum date.

public string $format = null
doc_Yii
2016-10-30 17:13:27
Comments
Leave a Comment

Please login to continue.