diff --git a/reference/constraints/DateTime.rst b/reference/constraints/DateTime.rst index 56a3777f627..7eeda011892 100644 --- a/reference/constraints/DateTime.rst +++ b/reference/constraints/DateTime.rst @@ -3,12 +3,13 @@ DateTime Validates that a value is a valid "datetime", meaning either a ``DateTime`` object or a string (or an object that can be cast into a string) that follows -a valid YYYY-MM-DD HH:MM:SS format. +a specific format. +----------------+------------------------------------------------------------------------+ | Applies to | :ref:`property or method ` | +----------------+------------------------------------------------------------------------+ | Options | - `message`_ | +| | - `format`_ | | | - `payload`_ | +----------------+------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Validator\\Constraints\\DateTime` | @@ -85,4 +86,16 @@ message This message is shown if the underlying data is not a valid datetime. +format +~~~~~~ + +**type**: ``string`` **default**: ``Y-m-d H:i:s`` + +.. versionadded:: 2.8 + The ``format`` option was introduced in Symfony 2.8. + +This option allows to validate a custom date format. See `date_create_from_format`_ for formatting options. + .. include:: /reference/constraints/_payload-option.rst.inc + +.. _`date_create_from_format`: http://php.net/manual/en/datetime.createfromformat.php