Skip to content

[Clock] document DatePointType #20817

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

Merged
merged 1 commit into from
Mar 25, 2025
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
25 changes: 25 additions & 0 deletions components/clock.rst
Original file line number Diff line number Diff line change
@@ -269,6 +269,31 @@

.. _clock_writing-tests:

Storing DatePoints in Databases
-------------------------------

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

// src/Entity/Product.php
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

Check failure on line 281 in components/clock.rst

GitHub Actions / Code Blocks

[Missing class] Class, interface or trait with name "Doctrine\ORM\Mapping" does not exist
use Symfony\Component\Clock\DatePoint;

#[ORM\Entity]
class Product
{
#[ORM\Column]
private DatePoint $created;

// ...
}

.. versionadded:: 7.3

The `DatePointType` was introduced in Symfony 7.3.

Writing Time-Sensitive Tests
----------------------------