diff --git a/reference/constraints/DateTime.rst b/reference/constraints/DateTime.rst index 5eeddff77c4..0a46668f1f4 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`_ | +| Options | - `format`_ | +| | - `message`_ | | | - `payload`_ | +----------------+------------------------------------------------------------------------+ | Class | :class:`Symfony\\Component\\Validator\\Constraints\\DateTime` | @@ -78,6 +79,17 @@ Basic Usage Options ------- +format +~~~~~~ + +**type**: ``string`` **default**: ``Y-m-d H:i:s`` + +.. versionadded:: 3.1 + The ``format`` option was introduced in Symfony 3.1. + +This option allows to validate a custom date format. +See `DateTime::createFromFormat `_ for formatting options. + message ~~~~~~~ @@ -86,3 +98,5 @@ message This message is shown if the underlying data is not a valid datetime. .. include:: /reference/constraints/_payload-option.rst.inc + +.. _`date_create_from_format`: http://php.net/manual/en/datetime.createfromformat.php