Skip to content
Open
Show file tree
Hide file tree
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
71 changes: 71 additions & 0 deletions reference/datetime/datetime/createfromtimestamp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="datetime.createfromtimestamp" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>DateTime::createFromTimestamp</refname>
<refpurpose>Returns a new DateTime instance encapsulating the given timestamp</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="DateTime">
<modifier>public</modifier> <modifier>static</modifier> <type>static</type><methodname>DateTime::createFromTimestamp</methodname>
<methodparam><type>int|float</type><parameter>timestamp</parameter></methodparam>
</methodsynopsis>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>timestamp</parameter></term>
<listitem>
<simpara>
A Unix timestamp.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
Returns a new <classname>DateTime</classname> instance.
</simpara>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<example>
<title>Creating a date time object from a timestamp</title>
<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>
</example>
</refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
71 changes: 71 additions & 0 deletions reference/datetime/datetimeimmutable/createfromtimestamp.xml
Original file line number Diff line number Diff line change
@@ -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">

<refnamediv>
<refname>DateTimeImmutable::createFromTimestamp</refname>
<refpurpose>Returns a new DateTimeImmutable instance encapsulating the given timestamp</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="DateTimeImmutable">
<modifier>public</modifier> <modifier>static</modifier> <type>static</type><methodname>DateTimeImmutable::createFromTimestamp</methodname>
<methodparam><type>int|float</type><parameter>timestamp</parameter></methodparam>
</methodsynopsis>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>timestamp</parameter></term>
<listitem>
<simpara>
A Unix timestamp.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
Returns a new <classname>DateTimeImmutable</classname> instance.
</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.

&reftitle.examples;
<example>
<title>Creating a date time object from a timestamp</title>
<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.

]]>
</programlisting>
</example>
</refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
2 changes: 2 additions & 0 deletions reference/datetime/versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<function name="datetime::createfromformat" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
<function name="datetime::createfromimmutable" from="PHP 7 &gt;= 7.3.0, PHP 8"/>
<function name="datetime::createfrominterface" from="PHP 8"/>
<function name="datetime::createfromtimestamp" from="PHP 8 &gt;= 8.4.0"/>
<function name="datetime::diff" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
<function name="datetime::format" from="PHP 5 &gt;= 5.2.1, PHP 7, PHP 8"/>
<function name="datetime::getlasterrors" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
Expand Down Expand Up @@ -48,6 +49,7 @@
<function name="datetimeimmutable::createfromformat" from="PHP 5 &gt;= 5.5.0, PHP 7, PHP 8"/>
<function name="datetimeimmutable::createfrommutable" from="PHP 5 &gt;= 5.6.0, PHP 7, PHP 8"/>
<function name="datetimeimmutable::createfrominterface" from="PHP 8"/>
<function name="datetimeimmutable::createfromtimestamp" from="PHP 8 &gt;= 8.4.0"/>
<function name="datetimeimmutable::diff" from="PHP 5 &gt;= 5.5.0, PHP 7, PHP 8"/>
<function name="datetimeimmutable::format" from="PHP 5 &gt;= 5.5.0, PHP 7, PHP 8"/>
<function name="datetimeimmutable::getlasterrors" from="PHP 5 &gt;= 5.5.0, PHP 7, PHP 8"/>
Expand Down