@@ -267,13 +267,11 @@ timestamps::
267
267
:method: `Symfony\\ Component\\ Clock\\ DatePoint::getMicrosecond ` methods were
268
268
introduced in Symfony 7.1.
269
269
270
- .. _clock_writing-tests :
271
-
272
- Storing DatePoints in Databases
273
- -------------------------------
270
+ Storing DatePoints in the Database
271
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
274
272
275
- If you :doc: `use Doctrine </doctrine >`, consider using the `` date_point `` Doctrine
276
- type, which converts to/from ``DatePoint `` objects automatically::
273
+ If you :doc: `use Doctrine </doctrine >` to work with databases , consider using the
274
+ `` date_point `` Doctrine type, which converts to/from ``DatePoint `` objects automatically::
277
275
278
276
// src/Entity/Product.php
279
277
namespace App\Entity;
@@ -284,15 +282,22 @@ type, which converts to/from ``DatePoint`` objects automatically::
284
282
#[ORM\Entity]
285
283
class Product
286
284
{
285
+ // if you don't define the Doctrine type explicitly, Symfony will autodetect it:
287
286
#[ORM\Column]
288
- private DatePoint $created;
287
+ private DatePoint $createdAt;
288
+
289
+ // if you prefer to define the Doctrine type explicitly:
290
+ #[ORM\Column(type: 'date_point')]
291
+ private DatePoint $updatedAt;
289
292
290
293
// ...
291
294
}
292
295
293
296
.. versionadded :: 7.3
294
297
295
- The `DatePointType ` was introduced in Symfony 7.3.
298
+ The ``DatePointType `` was introduced in Symfony 7.3.
299
+
300
+ .. _clock_writing-tests :
296
301
297
302
Writing Time-Sensitive Tests
298
303
----------------------------
0 commit comments