svn: /phpdoc/en/trunk/reference/datetime/datetime/ settimestamp.xml
| From: | Adam Harvey | Date: | Tue, 20 Jul 2010 04:25:14 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/datetime/datetime/ settimestamp.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-6897@lists.php.net to get a copy of this message | ||
aharvey Tue, 20 Jul 2010 04:25:14 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=301411
Log:
Per doc bug #52378 (new DateTime(time()) failed and should not), clarified how
you can emulate the functionality of DateTime::setTimestamp() in PHP 5.2 with
an example.
Bug: http://bugs.php.net/52378 (error getting bug
information)
Changed paths:
U phpdoc/en/trunk/reference/datetime/datetime/settimestamp.xml
Modified: phpdoc/en/trunk/reference/datetime/datetime/settimestamp.xml
===================================================================
--- phpdoc/en/trunk/reference/datetime/datetime/settimestamp.xml 2010-07-20 00:20:37 UTC (rev
301410)
+++ phpdoc/en/trunk/reference/datetime/datetime/settimestamp.xml 2010-07-20 04:25:14 UTC (rev
301411)
@@ -88,10 +88,29 @@
<refsect1 role="notes">
&reftitle.notes;
<para>
- Passing a Unix timestamp to
- <function>DateTime::__construct</function>
- is an alternative when using PHP 5.2.
+ Using the Unix timestamp format to construct a new <type>DateTime</type>
+ object is an alternative when using PHP 5.2, as shown in the example below.
</para>
+ <example>
+ <title>
+ <function>DateTime::setTimestamp</function> alternative in PHP 5.2
+ </title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$ts = 1171502725;
+$date = new DateTime("@$ts");
+echo $date->format('U = Y-m-d H:i:s') . "\n";
+?>
+]]>
+ </programlisting>
+ &example.outputs.similar;
+ <screen>
+<![CDATA[
+1171502725 = 2007-02-14 20:25:25
+]]>
+ </screen>
+ </example>
</refsect1>
<refsect1 role="seealso">