File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,21 @@ The constructor also allows setting a timezone or custom referenced date::
229
229
$referenceDate = new \DateTimeImmutable();
230
230
$relativeDate = new DatePoint('+1month', reference: $referenceDate);
231
231
232
+ The ``DatePoint `` class also provides a named constructor to create dates from
233
+ timestamps::
234
+
235
+ $dateOfFirstCommitOfSymfonyProject = DatePoint::createFromTimestamp(1129645656);
236
+ // equivalent to:
237
+ // $dateOfFirstCommitOfSymfonyProject = (new \DateTimeImmutable())->setTimestamp(1129645656);
238
+
239
+ // negative timestamps (for dates before January 1, 1970) and fractional timestamps
240
+ // (for high precision sub-second datetimes) are also supported
241
+ $dateOfFirstMoonLanding = DatePoint::createFromTimestamp(-14182940);
242
+
243
+ .. versionadded :: 7.1
244
+
245
+ The ``createFromTimestamp() `` method was introduced in Symfony 7.1.
246
+
232
247
.. note ::
233
248
234
249
In addition ``DatePoint `` offers stricter return types and provides consistent
You can’t perform that action at this time.
0 commit comments