Skip to content

Commit 7eb958f

Browse files
committed
minor #19768 [Clock] Document createFromTimestamp() method (javiereguiluz)
This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [Clock] Document createFromTimestamp() method Fixes #19766 Commits ------- 9bd321d [Clock] Document createFromTimestamp() method
2 parents 078d6f9 + 9bd321d commit 7eb958f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

components/clock.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,21 @@ The constructor also allows setting a timezone or custom referenced date::
229229
$referenceDate = new \DateTimeImmutable();
230230
$relativeDate = new DatePoint('+1month', reference: $referenceDate);
231231

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+
232247
.. note::
233248

234249
In addition ``DatePoint`` offers stricter return types and provides consistent

0 commit comments

Comments
 (0)