Skip to content

Document createFromTimestamp() for DateTime and DateTimeImmutable#5103

Open
mathroc wants to merge 2 commits intophp:masterfrom
mathroc:datetime-from-timestamp
Open

Document createFromTimestamp() for DateTime and DateTimeImmutable#5103
mathroc wants to merge 2 commits intophp:masterfrom
mathroc:datetime-from-timestamp

Conversation

@mathroc
Copy link

@mathroc mathroc commented Jan 14, 2026

disclaimer: first time contributing here and edited from github web IDE. I didn't check if it's remotely close to be OK yet

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preliminary markup review.

Co-authored-by: Gina Peter Banyard <girgias@php.net>
@Girgias Girgias marked this pull request as ready for review February 6, 2026 14:11
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="datetimeimmutble.createfromtimestamp" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<refentry xml:id="datetimeimmutble.createfromtimestamp" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refentry xml:id="datetimeimmutable.createfromtimestamp" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">

<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php
$dt = DateTime::createFromTimestamp( 1403261100 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it could be interesting to add an example with a float as a parameter ?

<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php
$dt = DateTimeImmutable::createFromTimestamp( 1403261100 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</simpara>
</refsect1>

<refsect1 role="examples">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great to add a section errors and seealso. The implementation throws DateRangeError for NaN or out-of-range float timestamps. Worth documenting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants