Skip to content
Merged
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
24 changes: 22 additions & 2 deletions components/clock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,17 @@ Storing DatePoints in the Database
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you :doc:`use Doctrine </doctrine>` to work with databases, consider using the
``date_point`` Doctrine type, which converts to/from ``DatePoint`` objects automatically::
new Doctrine types:

======================= ====================== =====
DatePoint Doctrine type Extends Doctrine type Class
======================= ====================== =====
``date_point`` ``datetime_immutable`` :class:`Symfony\\Bridge\\Doctrine\\Types\\DatePointType`
``day_point`` ``date_immutable`` :class:`Symfony\\Bridge\\Doctrine\\Types\\DayPointType`
``time_point`` ``time_immutable`` :class:`Symfony\\Bridge\\Doctrine\\Types\\TimePointType`
======================= ====================== =====

They convert to/from ``DatePoint`` objects automatically::

// src/Entity/Product.php
namespace App\Entity;
Expand All @@ -282,21 +292,31 @@ If you :doc:`use Doctrine </doctrine>` to work with databases, consider using th
#[ORM\Entity]
class Product
{
// if you don't define the Doctrine type explicitly, Symfony will autodetect it:
// if you don't define the Doctrine type explicitly, Symfony will autodetect 'date_point':
#[ORM\Column]
private DatePoint $createdAt;

// if you prefer to define the Doctrine type explicitly:
#[ORM\Column(type: 'date_point')]
private DatePoint $updatedAt;

#[ORM\Column(type: 'day_point')]
public DatePoint $birthday;

#[ORM\Column(type: 'time_point')]
public DatePoint $openAt;

// ...
}

.. versionadded:: 7.3

The ``DatePointType`` was introduced in Symfony 7.3.

.. versionadded:: 7.4

The ``DayPointType`` and ``TimePointType`` were introduced in Symfony 7.4.

.. _clock_writing-tests:

Writing Time-Sensitive Tests
Expand Down