File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,13 @@ DateTime
3
3
4
4
Validates that a value is a valid "datetime", meaning either a ``DateTime ``
5
5
object or a string (or an object that can be cast into a string) that follows
6
- a valid YYYY-MM-DD HH :MM: SS format.
6
+ a specific format.
7
7
8
8
+----------------+------------------------------------------------------------------------+
9
9
| Applies to | :ref: `property or method <validation-property-target >` |
10
10
+----------------+------------------------------------------------------------------------+
11
- | Options | - `message `_ |
11
+ | Options | - `format `_ |
12
+ | | - `message `_ |
12
13
| | - `payload `_ |
13
14
+----------------+------------------------------------------------------------------------+
14
15
| Class | :class: `Symfony\\ Component\\ Validator\\ Constraints\\ DateTime ` |
@@ -78,6 +79,17 @@ Basic Usage
78
79
Options
79
80
-------
80
81
82
+ format
83
+ ~~~~~~
84
+
85
+ **type **: ``string `` **default **: ``Y-m-d H:i:s ``
86
+
87
+ .. versionadded :: 3.1
88
+ The ``format `` option was introduced in Symfony 3.1.
89
+
90
+ This option allows to validate a custom date format.
91
+ See `DateTime::createFromFormat <date_create_from_format >`_ for formatting options.
92
+
81
93
message
82
94
~~~~~~~
83
95
@@ -86,3 +98,5 @@ message
86
98
This message is shown if the underlying data is not a valid datetime.
87
99
88
100
.. include :: /reference/constraints/_payload-option.rst.inc
101
+
102
+ .. _`date_create_from_format` : http://php.net/manual/en/datetime.createfromformat.php
You can’t perform that action at this time.
0 commit comments