Skip to content

[WCM][Config] Add a \DateTime node and definition #7226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions components/config/definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,38 @@ values::

This will restrict the ``gender`` option to be either ``male`` or ``female``.

DateTime Nodes
~~~~~~~~~~~~~~

DateTime nodes provide a way to get a ``\DateTime`` instance normalized
from configuration::

$rootNode
->children()
->datetimeNode('datetime')
->format('d/m/Y')
->timezone('Europe/Paris')
->end()
->end()
;

Such nodes accept both an integer (a timestamp) or a string as value.
If the provided value is a string, it should be interpretable by ``strtotime``
or match the format provided using the ``format()`` method.

DateTime Node Options
~~~~~~~~~~~~~~~~~~~~~

You can optionally provide the following options:

``format()``
If provided and the node value is a string, the node will try to parse the
datetime according to given format.

``timezone()``
If provided and the node value is a string, the node will set the
``\DateTime`` instance timezone using this value.

Array Nodes
~~~~~~~~~~~

Expand Down