From 23b31d13dee2cdbc815f867da0b639e38d1f018c Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 10 May 2015 15:47:16 +0200 Subject: [PATCH] improve documentation of date validator fixes #7514 --- framework/validators/DateValidator.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/framework/validators/DateValidator.php b/framework/validators/DateValidator.php index 2b9d16bd53..b7f893db8f 100644 --- a/framework/validators/DateValidator.php +++ b/framework/validators/DateValidator.php @@ -15,7 +15,15 @@ use yii\base\InvalidConfigException; use yii\helpers\FormatConverter; /** - * DateValidator verifies if the attribute represents a date, time or datetime in a proper format. + * DateValidator verifies if the attribute represents a date, time or datetime in a proper [[format]]. + * + * It can also parse internationalized dates in a specific [[locale]] like e.g. `12 мая 2014` when [[format]] + * is configured to use a time pattern in ICU format. + * + * It is further possible to limit the date within a certain range using [[min]] and [[max]]. + * + * Additional to validating the date it can also export the parsed timestamp as a machine readable format + * which can be configured using [[timestampAttribute]]. * * @author Qiang Xue * @author Carsten Brandt @@ -39,6 +47,14 @@ class DateValidator extends Validator * '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](http://php.net/manual/en/book.intl.php) is installed, the [IntlDateFormatter](http://php.net/manual/en/intldateformatter.parse.php) + * is used to parse the input value. In all other cases the PHP [DateTime](http://php.net/manual/en/datetime.createfromformat.php) 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 [[min|minimum date]]. */ public $format; /**