Skip to content

Commit db34cce

Browse files
committed
document DatePointType
1 parent 0d01dbc commit db34cce

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

components/clock.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,29 @@ When using the Clock component, you manipulate
7575
:class:`Symfony\\Component\\Clock\\DatePoint` instances. You can learn more
7676
about it in :ref:`the dedicated section <clock_date-point>`.
7777

78+
Storing DatePoints in Databases
79+
-------------------------------
80+
81+
If you :doc:`use Doctrine </doctrine>`, consider using the ``date_point`` Doctrine
82+
type, which converts to/from DatePoint objects automatically::
83+
84+
// src/Entity/Product.php
85+
namespace App\Entity;
86+
87+
use Doctrine\ORM\Mapping as ORM;
88+
use Symfony\Bridge\Doctrine\Types\DatePointType;
89+
use Symfony\Component\Clock\DatePoint;
90+
91+
#[ORM\Entity(repositoryClass: ProductRepository::class)]
92+
class Product
93+
{
94+
#[ORM\Column(type: DatePointType::NAME)]
95+
private DatePoint $created;
96+
97+
// ...
98+
}
99+
100+
78101
Available Clocks Implementations
79102
--------------------------------
80103

0 commit comments

Comments
 (0)